Add option to sort library by source. (#985)
* Add option to sort library by source. * Implement change suggested by NoodleMage.
This commit is contained in:
parent
b85c164195
commit
74fd70416f
3 changed files with 11 additions and 1 deletions
|
@ -117,7 +117,9 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
||||||
|
|
||||||
private val unread = Item.MultiSort(R.string.action_filter_unread, this)
|
private val unread = Item.MultiSort(R.string.action_filter_unread, this)
|
||||||
|
|
||||||
override val items = listOf(alphabetically, lastRead, lastUpdated, unread, total)
|
private val source = Item.MultiSort(R.string.manga_info_source_label, this)
|
||||||
|
|
||||||
|
override val items = listOf(alphabetically, lastRead, lastUpdated, unread, total, source)
|
||||||
|
|
||||||
override val header = Item.Header(R.string.action_sort)
|
override val header = Item.Header(R.string.action_sort)
|
||||||
|
|
||||||
|
@ -133,6 +135,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
||||||
lastUpdated.state = if (sorting == LibrarySort.LAST_UPDATED) order else SORT_NONE
|
lastUpdated.state = if (sorting == LibrarySort.LAST_UPDATED) order else SORT_NONE
|
||||||
unread.state = if (sorting == LibrarySort.UNREAD) order else SORT_NONE
|
unread.state = if (sorting == LibrarySort.UNREAD) order else SORT_NONE
|
||||||
total.state = if (sorting == LibrarySort.TOTAL) order else SORT_NONE
|
total.state = if (sorting == LibrarySort.TOTAL) order else SORT_NONE
|
||||||
|
source.state = if (sorting == LibrarySort.SOURCE) order else SORT_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClicked(item: Item) {
|
override fun onItemClicked(item: Item) {
|
||||||
|
@ -153,6 +156,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
||||||
lastUpdated -> LibrarySort.LAST_UPDATED
|
lastUpdated -> LibrarySort.LAST_UPDATED
|
||||||
unread -> LibrarySort.UNREAD
|
unread -> LibrarySort.UNREAD
|
||||||
total -> LibrarySort.TOTAL
|
total -> LibrarySort.TOTAL
|
||||||
|
source -> LibrarySort.SOURCE
|
||||||
else -> throw Exception("Unknown sorting")
|
else -> throw Exception("Unknown sorting")
|
||||||
})
|
})
|
||||||
preferences.librarySortingAscending().set(if (item.state == SORT_ASC) true else false)
|
preferences.librarySortingAscending().set(if (item.state == SORT_ASC) true else false)
|
||||||
|
|
|
@ -174,6 +174,11 @@ class LibraryPresenter(
|
||||||
val mange2TotalChapter = totalChapterManga[manga2.id!!] ?: 0
|
val mange2TotalChapter = totalChapterManga[manga2.id!!] ?: 0
|
||||||
manga1TotalChapter.compareTo(mange2TotalChapter)
|
manga1TotalChapter.compareTo(mange2TotalChapter)
|
||||||
}
|
}
|
||||||
|
LibrarySort.SOURCE -> {
|
||||||
|
val source1Name = sourceManager.get(manga1.source)?.name ?: ""
|
||||||
|
val source2Name = sourceManager.get(manga2.source)?.name ?: ""
|
||||||
|
source1Name.compareTo(source2Name)
|
||||||
|
}
|
||||||
else -> throw Exception("Unknown sorting mode")
|
else -> throw Exception("Unknown sorting mode")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,5 @@ object LibrarySort {
|
||||||
const val LAST_UPDATED = 2
|
const val LAST_UPDATED = 2
|
||||||
const val UNREAD = 3
|
const val UNREAD = 3
|
||||||
const val TOTAL = 4
|
const val TOTAL = 4
|
||||||
|
const val SOURCE = 5
|
||||||
}
|
}
|
Reference in a new issue