mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
feat: Display the number of filtered manga in each category's
header when searching in library (#387)
This commit is contained in:
parent
f13f98f19a
commit
8be33e0f81
2 changed files with 12 additions and 1 deletions
|
@ -173,6 +173,7 @@ class LibraryCategoryAdapter(val controller: LibraryController?) :
|
|||
}
|
||||
isLongPressDragEnabled = libraryListener?.canDrag() == true && s.isNullOrBlank()
|
||||
setItemsPerCategoryMap()
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun getFirstLetter(name: String): String {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue