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 87187ab75..a0676bcd9 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