mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Support categories in filtered library/stats
ok so I did the last one
This commit is contained in:
parent
0b9cf41c75
commit
21cd9c7f6a
6 changed files with 26 additions and 5 deletions
|
@ -7,7 +7,6 @@ import android.view.View
|
|||
import androidx.core.view.isVisible
|
||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||
import eu.kanade.tachiyomi.util.view.collapse
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bundle) {
|
||||
|
||||
|
@ -28,6 +27,8 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
|||
private set
|
||||
var filterLength: IntRange? = null
|
||||
private set
|
||||
var filterCategories = emptyArray<Int>()
|
||||
private set
|
||||
|
||||
private var customTitle: String? = null
|
||||
|
||||
|
@ -42,6 +43,7 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
|||
filterSources: Array<Long> = emptyArray(),
|
||||
filterMangaType: Array<Int> = emptyArray(),
|
||||
filterLanguages: Array<String> = emptyArray(),
|
||||
filterCategories: Array<Int> = emptyArray(),
|
||||
filterTracked: Int = 0,
|
||||
filterTrackerName: String? = null,
|
||||
filterTrackingScore: Int = 0,
|
||||
|
@ -54,6 +56,7 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
|||
this.filterSources = filterSources
|
||||
this.filterTracked = filterTracked
|
||||
this.filterMangaType = filterMangaType
|
||||
this.filterCategories = filterCategories
|
||||
if (filterTracked != 0 && filterTrackerName != null) {
|
||||
FilterBottomSheet.FILTER_TRACKER = filterTrackerName
|
||||
}
|
||||
|
|
|
@ -160,8 +160,15 @@ class LibraryHeaderHolder(val view: View, val adapter: LibraryCategoryAdapter) :
|
|||
binding.rearView.updatePadding(top = binding.categoryTitle.marginTop - 6)
|
||||
val category = item.category
|
||||
|
||||
binding.categoryTitle.text =
|
||||
if (category.isAlone && !category.isDynamic) { "" } else { category.name } +
|
||||
val categoryName = if (category.isAlone && !category.isDynamic ||
|
||||
(adapter.libraryListener as? FilteredLibraryController)?.filterCategories?.size == 1
|
||||
) {
|
||||
""
|
||||
} else {
|
||||
category.name
|
||||
}
|
||||
|
||||
binding.categoryTitle.text = categoryName +
|
||||
if (adapter.showNumber) {
|
||||
" (${adapter.itemsPerCategory[item.catId]})"
|
||||
} else { "" }
|
||||
|
|
|
@ -431,6 +431,10 @@ class LibraryPresenter(
|
|||
if (mangaLength != null) {
|
||||
if (item.manga.totalChapters !in mangaLength) return false
|
||||
}
|
||||
val categories = customFilters.filterCategories
|
||||
if (categories.isNotEmpty()) {
|
||||
if (item.manga.category !in categories) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ class StatsDetailsAdapter(
|
|||
holder.itemView.setOnClickListener {
|
||||
list[position].let { item -> listener?.onItemClicked(item.id, item.label) }
|
||||
}
|
||||
holder.itemView.isClickable = stat != Stats.CATEGORY
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
|
|
@ -597,9 +597,10 @@ class StatsDetailsController :
|
|||
val languages = presenter.selectedLanguage.mapNotNull { lang ->
|
||||
presenter.languagesStats.firstNotNullOfOrNull { if (it.value == lang) it.key else null }
|
||||
}.toTypedArray()
|
||||
val categories = presenter.selectedCategory.mapNotNull { it.id }.toTypedArray()
|
||||
val sources = presenter.selectedSource.map { it.id }.toTypedArray()
|
||||
when (val selectedStat = presenter.selectedStat) {
|
||||
Stats.SOURCE, Stats.TAG, Stats.STATUS, Stats.SERIES_TYPE, Stats.SCORE, Stats.START_YEAR, Stats.LANGUAGE -> {
|
||||
Stats.SOURCE, Stats.TAG, Stats.STATUS, Stats.SERIES_TYPE, Stats.SCORE, Stats.START_YEAR, Stats.LANGUAGE, Stats.CATEGORY -> {
|
||||
router.pushController(
|
||||
FilteredLibraryController(
|
||||
if (selectedStat == Stats.SCORE) {
|
||||
|
@ -630,6 +631,10 @@ class StatsDetailsController :
|
|||
}
|
||||
else -> languages
|
||||
},
|
||||
filterCategories = when (selectedStat) {
|
||||
Stats.CATEGORY -> arrayOf(id!!.toInt())
|
||||
else -> categories
|
||||
},
|
||||
filterTrackingScore = if (selectedStat == Stats.SCORE) id?.toInt() ?: -1 else 0,
|
||||
filterStartYear = if (selectedStat == Stats.START_YEAR) id?.toInt() ?: -1 else 0,
|
||||
).withFadeTransaction(),
|
||||
|
@ -648,6 +653,7 @@ class StatsDetailsController :
|
|||
filterStatus = statuses,
|
||||
filterSources = sources,
|
||||
filterLanguages = languages,
|
||||
filterCategories = categories,
|
||||
filterTracked = if (serviceName == null) {
|
||||
FilterBottomSheet.STATE_EXCLUDE
|
||||
} else {
|
||||
|
@ -674,6 +680,7 @@ class StatsDetailsController :
|
|||
filterStatus = statuses,
|
||||
filterSources = sources,
|
||||
filterLanguages = languages,
|
||||
filterCategories = categories,
|
||||
filterLength = range,
|
||||
).withFadeTransaction(),
|
||||
)
|
||||
|
|
|
@ -313,6 +313,7 @@ class StatsDetailsPresenter(
|
|||
totalChapters = mangaList.sumOf { it.totalChapters },
|
||||
label = label,
|
||||
readDuration = mangaList.getReadDuration(),
|
||||
id = category.toLong(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue