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 androidx.core.view.isVisible
|
||||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||||
import eu.kanade.tachiyomi.util.view.collapse
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
|
|
||||||
class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bundle) {
|
class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bundle) {
|
||||||
|
|
||||||
|
@ -28,6 +27,8 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
||||||
private set
|
private set
|
||||||
var filterLength: IntRange? = null
|
var filterLength: IntRange? = null
|
||||||
private set
|
private set
|
||||||
|
var filterCategories = emptyArray<Int>()
|
||||||
|
private set
|
||||||
|
|
||||||
private var customTitle: String? = null
|
private var customTitle: String? = null
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
||||||
filterSources: Array<Long> = emptyArray(),
|
filterSources: Array<Long> = emptyArray(),
|
||||||
filterMangaType: Array<Int> = emptyArray(),
|
filterMangaType: Array<Int> = emptyArray(),
|
||||||
filterLanguages: Array<String> = emptyArray(),
|
filterLanguages: Array<String> = emptyArray(),
|
||||||
|
filterCategories: Array<Int> = emptyArray(),
|
||||||
filterTracked: Int = 0,
|
filterTracked: Int = 0,
|
||||||
filterTrackerName: String? = null,
|
filterTrackerName: String? = null,
|
||||||
filterTrackingScore: Int = 0,
|
filterTrackingScore: Int = 0,
|
||||||
|
@ -54,6 +56,7 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
||||||
this.filterSources = filterSources
|
this.filterSources = filterSources
|
||||||
this.filterTracked = filterTracked
|
this.filterTracked = filterTracked
|
||||||
this.filterMangaType = filterMangaType
|
this.filterMangaType = filterMangaType
|
||||||
|
this.filterCategories = filterCategories
|
||||||
if (filterTracked != 0 && filterTrackerName != null) {
|
if (filterTracked != 0 && filterTrackerName != null) {
|
||||||
FilterBottomSheet.FILTER_TRACKER = filterTrackerName
|
FilterBottomSheet.FILTER_TRACKER = filterTrackerName
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,8 +160,15 @@ class LibraryHeaderHolder(val view: View, val adapter: LibraryCategoryAdapter) :
|
||||||
binding.rearView.updatePadding(top = binding.categoryTitle.marginTop - 6)
|
binding.rearView.updatePadding(top = binding.categoryTitle.marginTop - 6)
|
||||||
val category = item.category
|
val category = item.category
|
||||||
|
|
||||||
binding.categoryTitle.text =
|
val categoryName = if (category.isAlone && !category.isDynamic ||
|
||||||
if (category.isAlone && !category.isDynamic) { "" } else { category.name } +
|
(adapter.libraryListener as? FilteredLibraryController)?.filterCategories?.size == 1
|
||||||
|
) {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
category.name
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.categoryTitle.text = categoryName +
|
||||||
if (adapter.showNumber) {
|
if (adapter.showNumber) {
|
||||||
" (${adapter.itemsPerCategory[item.catId]})"
|
" (${adapter.itemsPerCategory[item.catId]})"
|
||||||
} else { "" }
|
} else { "" }
|
||||||
|
|
|
@ -431,6 +431,10 @@ class LibraryPresenter(
|
||||||
if (mangaLength != null) {
|
if (mangaLength != null) {
|
||||||
if (item.manga.totalChapters !in mangaLength) return false
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ class StatsDetailsAdapter(
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
list[position].let { item -> listener?.onItemClicked(item.id, item.label) }
|
list[position].let { item -> listener?.onItemClicked(item.id, item.label) }
|
||||||
}
|
}
|
||||||
holder.itemView.isClickable = stat != Stats.CATEGORY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
|
|
@ -597,9 +597,10 @@ class StatsDetailsController :
|
||||||
val languages = presenter.selectedLanguage.mapNotNull { lang ->
|
val languages = presenter.selectedLanguage.mapNotNull { lang ->
|
||||||
presenter.languagesStats.firstNotNullOfOrNull { if (it.value == lang) it.key else null }
|
presenter.languagesStats.firstNotNullOfOrNull { if (it.value == lang) it.key else null }
|
||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
|
val categories = presenter.selectedCategory.mapNotNull { it.id }.toTypedArray()
|
||||||
val sources = presenter.selectedSource.map { it.id }.toTypedArray()
|
val sources = presenter.selectedSource.map { it.id }.toTypedArray()
|
||||||
when (val selectedStat = presenter.selectedStat) {
|
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(
|
router.pushController(
|
||||||
FilteredLibraryController(
|
FilteredLibraryController(
|
||||||
if (selectedStat == Stats.SCORE) {
|
if (selectedStat == Stats.SCORE) {
|
||||||
|
@ -630,6 +631,10 @@ class StatsDetailsController :
|
||||||
}
|
}
|
||||||
else -> languages
|
else -> languages
|
||||||
},
|
},
|
||||||
|
filterCategories = when (selectedStat) {
|
||||||
|
Stats.CATEGORY -> arrayOf(id!!.toInt())
|
||||||
|
else -> categories
|
||||||
|
},
|
||||||
filterTrackingScore = if (selectedStat == Stats.SCORE) id?.toInt() ?: -1 else 0,
|
filterTrackingScore = if (selectedStat == Stats.SCORE) id?.toInt() ?: -1 else 0,
|
||||||
filterStartYear = if (selectedStat == Stats.START_YEAR) id?.toInt() ?: -1 else 0,
|
filterStartYear = if (selectedStat == Stats.START_YEAR) id?.toInt() ?: -1 else 0,
|
||||||
).withFadeTransaction(),
|
).withFadeTransaction(),
|
||||||
|
@ -648,6 +653,7 @@ class StatsDetailsController :
|
||||||
filterStatus = statuses,
|
filterStatus = statuses,
|
||||||
filterSources = sources,
|
filterSources = sources,
|
||||||
filterLanguages = languages,
|
filterLanguages = languages,
|
||||||
|
filterCategories = categories,
|
||||||
filterTracked = if (serviceName == null) {
|
filterTracked = if (serviceName == null) {
|
||||||
FilterBottomSheet.STATE_EXCLUDE
|
FilterBottomSheet.STATE_EXCLUDE
|
||||||
} else {
|
} else {
|
||||||
|
@ -674,6 +680,7 @@ class StatsDetailsController :
|
||||||
filterStatus = statuses,
|
filterStatus = statuses,
|
||||||
filterSources = sources,
|
filterSources = sources,
|
||||||
filterLanguages = languages,
|
filterLanguages = languages,
|
||||||
|
filterCategories = categories,
|
||||||
filterLength = range,
|
filterLength = range,
|
||||||
).withFadeTransaction(),
|
).withFadeTransaction(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -313,6 +313,7 @@ class StatsDetailsPresenter(
|
||||||
totalChapters = mangaList.sumOf { it.totalChapters },
|
totalChapters = mangaList.sumOf { it.totalChapters },
|
||||||
label = label,
|
label = label,
|
||||||
readDuration = mangaList.getReadDuration(),
|
readDuration = mangaList.getReadDuration(),
|
||||||
|
id = category.toLong(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue