From c9e22d898d9b8bfe802ad3a8701338ccc8ef9f70 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Tue, 27 Apr 2021 02:29:09 -0400 Subject: [PATCH] Random potential crash fixes --- .../java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt | 2 +- .../eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt index 47c649ee61..52564d8f5f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt @@ -73,7 +73,7 @@ class CategoryPresenter( val cat = Category.create(name) // Set the new item in the last position. - cat.order = categories.maxOf { it.order } + 1 + cat.order = (categories.maxOfOrNull { it.order } ?: 0) + 1 // Insert into database. cat.mangaSort = LibrarySort.Title.categoryValue diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt index 28fbb0c10d..1b5600f446 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt @@ -72,7 +72,7 @@ class LibraryCategoryAdapter(val controller: LibraryController) : fun findCategoryHeader(catId: Int): LibraryHeaderItem? { return currentItems.find { (it is LibraryHeaderItem) && it.category.id == catId - } as LibraryHeaderItem + } as? LibraryHeaderItem } /**