浏览代码

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

jmir1 3 年之前
父节点
当前提交
3448751e0e
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt

+ 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