mirror of
https://github.com/null2264/yokai.git
synced 2025-06-20 10:14:50 +00:00
fix: More "Comparison method violates its general contract!" prevention
This commit is contained in:
parent
cedf532ded
commit
d31cebfdfd
1 changed files with 5 additions and 6 deletions
|
@ -637,6 +637,9 @@ class LibraryPresenter(
|
|||
* @param itemList the map to sort.
|
||||
*/
|
||||
private fun List<LibraryItem>.applySort(): List<LibraryItem> {
|
||||
// Making sure `allCategories` is stable for `.sort()`Add commentMore actions
|
||||
val categoryOrderMap = allCategories.associate { it.id to it.order }
|
||||
|
||||
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
||||
if (i1.header.category.id == i2.header.category.id) {
|
||||
val category = i1.header.category
|
||||
|
@ -663,12 +666,8 @@ class LibraryPresenter(
|
|||
LibrarySort.DateAdded -> i2.manga.date_added.compareTo(i1.manga.date_added)
|
||||
LibrarySort.DragAndDrop -> {
|
||||
if (category.isDynamic) {
|
||||
val category1 =
|
||||
allCategories.find { i1.manga.category == it.id }?.order
|
||||
?: 0
|
||||
val category2 =
|
||||
allCategories.find { i2.manga.category == it.id }?.order
|
||||
?: 0
|
||||
val category1 = categoryOrderMap[i1.manga.category] ?: 0
|
||||
val category2 = categoryOrderMap[i2.manga.category] ?: 0
|
||||
category1.compareTo(category2)
|
||||
} else {
|
||||
sortAlphabetical(i1, i2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue