Преглед изворни кода

修复特定情况下的NPE问题

HapeLee пре 1 година
родитељ
комит
85d425e847
1 измењених фајлова са 2 додато и 1 уклоњено
  1. 2 1
      app/src/main/java/io/legato/kazusa/ui/book/toc/ChapterListAdapter.kt

+ 2 - 1
app/src/main/java/io/legato/kazusa/ui/book/toc/ChapterListAdapter.kt

@@ -81,7 +81,8 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
             val useReplace = AppConfig.tocUiUseReplace && book.getUseReplaceRule()
             val useReplace = AppConfig.tocUiUseReplace && book.getUseReplaceRule()
             val items = getItems()
             val items = getItems()
 
 
-            val indices = (startIndex until items.size) + (startIndex downTo 0)
+            val indices = ((startIndex until items.size) + (startIndex downTo 0))
+                .filter { it in items.indices }
 
 
             for (i in indices) {
             for (i in indices) {
                 val item = items[i]
                 val item = items[i]