mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
enhance(library): Show "category is empty" on filtered if the category is actually empty
This commit is contained in:
parent
25644af5cf
commit
a25df1eef3
3 changed files with 16 additions and 2 deletions
|
@ -14,6 +14,13 @@ data class LibraryManga(
|
|||
var lastFetch: Int = 0,
|
||||
) : MangaImpl() {
|
||||
|
||||
var realMangaCount = 0
|
||||
get() = if (isBlank()) field else throw IllegalStateException("realMangaCount is only accessible for placeholders")
|
||||
set(value) {
|
||||
if (!isBlank()) throw IllegalStateException("realMangaCount can only be set for placeholders")
|
||||
field = value
|
||||
}
|
||||
|
||||
val hasRead
|
||||
get() = read > 0
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class LibraryListHolder(
|
|||
binding.title.isVisible = false
|
||||
} else {
|
||||
binding.title.text = itemView.context.getString(
|
||||
if (adapter.hasActiveFilters) {
|
||||
if (adapter.hasActiveFilters && item.manga.realMangaCount >= 1) {
|
||||
R.string.no_matches_for_filters_short
|
||||
} else {
|
||||
R.string.category_is_empty
|
||||
|
|
|
@ -341,7 +341,12 @@ class LibraryPresenter(
|
|||
)
|
||||
hasActiveFilters = !filtersOff
|
||||
val missingCategorySet = categories.mapNotNull { it.id }.toMutableSet()
|
||||
val realCount = mutableMapOf<Int, Int>()
|
||||
val filteredItems = this.filter f@{ item ->
|
||||
if (showEmptyCategoriesWhileFiltering) {
|
||||
realCount[item.manga.category] = sectionedLibraryItems[item.manga.category]?.size ?: 0
|
||||
}
|
||||
|
||||
if (!showEmptyCategoriesWhileFiltering && item.manga.isHidden()) {
|
||||
val subItems = sectionedLibraryItems[item.manga.category]?.takeUnless { it.size <= 1 }
|
||||
?: hiddenLibraryItems.filter { it.manga.category == item.manga.category }
|
||||
|
@ -376,7 +381,9 @@ class LibraryPresenter(
|
|||
}.toMutableList()
|
||||
if (showEmptyCategoriesWhileFiltering) {
|
||||
missingCategorySet.forEach {
|
||||
filteredItems.add(blankItem(it).first())
|
||||
filteredItems.add(
|
||||
blankItem(it).first().apply { manga.realMangaCount = realCount[it] ?: 0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
return filteredItems
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue