Slight refactoring to library presenter

This commit is contained in:
Jay 2020-05-23 17:25:09 -04:00
parent a8d577e790
commit a15563d409

View File

@ -516,7 +516,7 @@ class LibraryPresenter(
this.allCategories = categories this.allCategories = categories
hashCategories = HashMap(this.categories.mapNotNull { hashCategories = HashMap(this.categories.map {
it.id!! to it it.id!! to it
}.toMap()) }.toMap())
@ -538,7 +538,7 @@ class LibraryPresenter(
} }
} }
val items = libraryManga.mapNotNull { manga -> val items = libraryManga.map { manga ->
when (groupType) { when (groupType) {
BY_TAG -> { BY_TAG -> {
val tags = if (manga.genre.isNullOrBlank()) { val tags = if (manga.genre.isNullOrBlank()) {
@ -840,7 +840,7 @@ class LibraryPresenter(
} }
fun toggleCategoryVisibility(categoryId: Int) { fun toggleCategoryVisibility(categoryId: Int) {
if (categoryId <= -1 || categories.find { it.id == categoryId }?.isDynamic == true) return if (categories.find { it.id == categoryId }?.isDynamic == true) return
val categoriesHidden = preferences.collapsedCategories().getOrDefault().mapNotNull { val categoriesHidden = preferences.collapsedCategories().getOrDefault().mapNotNull {
it.toIntOrNull() it.toIntOrNull()
}.toMutableSet() }.toMutableSet()
@ -854,7 +854,7 @@ class LibraryPresenter(
fun toggleAllCategoryVisibility() { fun toggleAllCategoryVisibility() {
if (preferences.collapsedCategories().getOrDefault().isEmpty()) { if (preferences.collapsedCategories().getOrDefault().isEmpty()) {
preferences.collapsedCategories().set(categories.map { it.id.toString() }.toMutableSet()) preferences.collapsedCategories().set(allCategories.map { it.id.toString() }.toMutableSet())
} else { } else {
preferences.collapsedCategories().set(mutableSetOf()) preferences.collapsedCategories().set(mutableSetOf())
} }