mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 07:15:10 +01:00
Enabled cat sorting
This commit is contained in:
parent
0cc96ef585
commit
24d592d999
@ -386,7 +386,6 @@ class LibraryController(
|
|||||||
|
|
||||||
bottom_sheet.lastCategory = adapter.categories.getOrNull(activeCat)
|
bottom_sheet.lastCategory = adapter.categories.getOrNull(activeCat)
|
||||||
bottom_sheet.updateTitle()
|
bottom_sheet.updateTitle()
|
||||||
bottom_sheet.setMainSortText()
|
|
||||||
|
|
||||||
tabsVisibilityRelay.call(categories.size > 1)
|
tabsVisibilityRelay.call(categories.size > 1)
|
||||||
|
|
||||||
|
@ -340,10 +340,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
popup.menuInflater.inflate(R.menu.cat_sort, popup.menu)
|
popup.menuInflater.inflate(R.menu.cat_sort, popup.menu)
|
||||||
|
|
||||||
// Set a listener so we are notified if a menu item is clicked
|
// Set a listener so we are notified if a menu item is clicked
|
||||||
/* popup.setOnMenuItemClickListener { menuItem ->
|
popup.setOnMenuItemClickListener { menuItem ->
|
||||||
onMainSortClicked(menuItem)
|
onCatSortClicked(menuItem)
|
||||||
true
|
true
|
||||||
}*/
|
}
|
||||||
popup.menu.findItem(R.id.action_reverse).isVisible = lastCategory?.mangaSort != null
|
popup.menu.findItem(R.id.action_reverse).isVisible = lastCategory?.mangaSort != null
|
||||||
|
|
||||||
// Finally show the PopupMenu
|
// Finally show the PopupMenu
|
||||||
@ -372,8 +372,38 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
onGroupClicked(ACTION_SORT)
|
onGroupClicked(ACTION_SORT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setMainSortText() {
|
private fun onCatSortClicked(menu: MenuItem) {
|
||||||
if (sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) return
|
val category = lastCategory ?: return
|
||||||
|
val modType = if (menu.itemId == R.id.action_reverse) {
|
||||||
|
val t = (category.mangaSort?.minus('a') ?: 0) + 1
|
||||||
|
if (t % 2 != 0) t + 1
|
||||||
|
else t - 1
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val order = when (menu.itemId) {
|
||||||
|
R.id.action_last_read -> 3
|
||||||
|
R.id.action_unread -> 2
|
||||||
|
R.id.action_update -> 1
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
(2 * order + 1)
|
||||||
|
}
|
||||||
|
setCatOrder(modType)
|
||||||
|
setCatSortText()
|
||||||
|
onGroupClicked(ACTION_SORT)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setCatOrder(order: Int) {
|
||||||
|
val category = lastCategory ?: return
|
||||||
|
category.mangaSort = ('a' + (order - 1))
|
||||||
|
if (category.id == 0)
|
||||||
|
preferences.defaultMangaOrder().set(category.mangaSort.toString())
|
||||||
|
else
|
||||||
|
Injekt.get<DatabaseHelper>().insertCategory(category).asRxObservable().subscribe()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setMainSortText() {
|
||||||
|
//if (sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) return
|
||||||
launchUI {
|
launchUI {
|
||||||
val sortId = withContext(Dispatchers.IO) { sorting(true) }
|
val sortId = withContext(Dispatchers.IO) { sorting(true) }
|
||||||
val drawable = withContext(Dispatchers.IO) {
|
val drawable = withContext(Dispatchers.IO) {
|
||||||
@ -417,7 +447,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
tintVector(
|
tintVector(
|
||||||
when {
|
when {
|
||||||
sortId == LibrarySort.DRAG_AND_DROP -> R.drawable.ic_sort_white_24dp
|
sortId == LibrarySort.DRAG_AND_DROP -> R.drawable.ic_sort_white_24dp
|
||||||
preferences.librarySortingAscending().getOrDefault() -> R.drawable
|
lastCategory?.isAscending() == true -> R.drawable
|
||||||
.ic_arrow_up_white_24dp
|
.ic_arrow_up_white_24dp
|
||||||
else -> R.drawable.ic_arrow_down_white_24dp
|
else -> R.drawable.ic_arrow_down_white_24dp
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user