feat: Display the number of filtered manga in each category's

header when searching in library (#387)
This commit is contained in:
Lee Shuen Fei 2025-04-15 07:05:15 +07:00 committed by Ahmad Ansori Palembani
parent f13f98f19a
commit 8be33e0f81
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 12 additions and 1 deletions

View file

@ -173,6 +173,7 @@ class LibraryCategoryAdapter(val controller: LibraryController?) :
}
isLongPressDragEnabled = libraryListener?.canDrag() == true && s.isNullOrBlank()
setItemsPerCategoryMap()
notifyDataSetChanged()
}
private fun getFirstLetter(name: String): String {

View file

@ -186,7 +186,17 @@ class LibraryHeaderHolder(val view: View, val adapter: LibraryCategoryAdapter) :
binding.categoryTitle.text = categoryName +
if (adapter.showNumber) {
" (${adapter.itemsPerCategory[item.catId]})"
val filteredCount = adapter.currentItems.count {
it is LibraryMangaItem && it.header?.catId == item.catId
}
val totalCount = adapter.itemsPerCategory[item.catId] ?: 0
val searchText = adapter.getFilter(String::class.java)
var countText = if (searchText.isNullOrBlank()) {
" ($totalCount)"
} else {
" ($filteredCount/$totalCount)"
}
countText
} else { "" }
if (category.sourceId != null) {
val icon = adapter.sourceManager.get(category.sourceId!!)?.icon()