From 3448751e0e2f1d96d547a019ce2d274c9be5a0e6 Mon Sep 17 00:00:00 2001 From: jmir1 <43830312+jmir1@users.noreply.github.com> Date: Mon, 11 Oct 2021 16:17:01 +0200 Subject: [PATCH] Fix crash when deleting last item in library (#6079) --- .../java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt index 87187ab757..a0676bcd97 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt @@ -139,9 +139,9 @@ class LibraryAdapter( } override fun getViewType(position: Int): Int { - val category = categories[position] - return if (isPerCategory && category.id != 0) { - if (DisplayModeSetting.fromFlag(category.displayMode) == DisplayModeSetting.LIST) { + val category = categories.getOrNull(position) + return if (isPerCategory && category?.id != 0) { + if (DisplayModeSetting.fromFlag(category?.displayMode) == DisplayModeSetting.LIST) { LIST_DISPLAY_MODE } else { GRID_DISPLAY_MODE