mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Prevent potential "Comparison method violates its general contract!" crash
This commit is contained in:
parent
8be33e0f81
commit
271e440014
2 changed files with 9 additions and 8 deletions
|
@ -16,6 +16,7 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
- Temporarily disable log file
|
- Temporarily disable log file
|
||||||
|
- Categories' header now show filtered count when you search the library (If you have "Show number of items" enabled)
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- Allow users to bypass onboarding's permission step if Shizuku is installed
|
- Allow users to bypass onboarding's permission step if Shizuku is installed
|
||||||
|
@ -23,6 +24,7 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
|
||||||
- Fix not fully loaded entries can't be selected on Library page
|
- Fix not fully loaded entries can't be selected on Library page
|
||||||
- Fix certain Infinix devices being unable to use any "Open link in browser" actions, including tracker setup (@MajorTanya)
|
- Fix certain Infinix devices being unable to use any "Open link in browser" actions, including tracker setup (@MajorTanya)
|
||||||
- Fix source filter bottom sheet unable to be fully scrolled to the bottom
|
- Fix source filter bottom sheet unable to be fully scrolled to the bottom
|
||||||
|
- Prevent potential "Comparison method violates its general contract!" crash
|
||||||
|
|
||||||
### Translation
|
### Translation
|
||||||
- Update translations from Weblate
|
- Update translations from Weblate
|
||||||
|
|
|
@ -660,6 +660,9 @@ class LibraryPresenter(
|
||||||
* @param itemList the map to sort.
|
* @param itemList the map to sort.
|
||||||
*/
|
*/
|
||||||
private fun LibraryMap.applySort(): LibraryMap {
|
private fun LibraryMap.applySort(): LibraryMap {
|
||||||
|
// Making sure `allCategories` is stable for `.sort()`
|
||||||
|
val categoryOrderMap = allCategories.associate { it.id to it.order }
|
||||||
|
|
||||||
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
||||||
val category = i1.header.category
|
val category = i1.header.category
|
||||||
val compare = when {
|
val compare = when {
|
||||||
|
@ -688,12 +691,8 @@ class LibraryPresenter(
|
||||||
LibrarySort.DateAdded -> i2.manga.manga.date_added.compareTo(i1.manga.manga.date_added)
|
LibrarySort.DateAdded -> i2.manga.manga.date_added.compareTo(i1.manga.manga.date_added)
|
||||||
LibrarySort.DragAndDrop -> {
|
LibrarySort.DragAndDrop -> {
|
||||||
if (category.isDynamic) {
|
if (category.isDynamic) {
|
||||||
val category1 =
|
val category1 = categoryOrderMap[i1.manga.category] ?: 0
|
||||||
allCategories.find { i1.manga.category == it.id }?.order
|
val category2 = categoryOrderMap[i2.manga.category] ?: 0
|
||||||
?: 0
|
|
||||||
val category2 =
|
|
||||||
allCategories.find { i2.manga.category == it.id }?.order
|
|
||||||
?: 0
|
|
||||||
category1.compareTo(category2)
|
category1.compareTo(category2)
|
||||||
} else {
|
} else {
|
||||||
sortAlphabetical(i1, i2)
|
sortAlphabetical(i1, i2)
|
||||||
|
@ -727,7 +726,7 @@ class LibraryPresenter(
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.mapValues { (category, values) ->
|
return this.mapValues { (category, values) ->
|
||||||
// Making sure category has valid sort
|
// Making sure category has valid sort before doing the actual sorting
|
||||||
if (category.mangaOrder.isEmpty() && category.mangaSort == null) {
|
if (category.mangaOrder.isEmpty() && category.mangaSort == null) {
|
||||||
category.changeSortTo(preferences.librarySortingMode().get())
|
category.changeSortTo(preferences.librarySortingMode().get())
|
||||||
if (category.id == 0) {
|
if (category.id == 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue