Procházet zdrojové kódy

Fix crash when deleting last item in library (#6079)

jmir1 před 3 roky
rodič
revize
3448751e0e

+ 3 - 3
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