Просмотр исходного кода

修复特定情况下的NPE问题

HapeLee 1 год назад
Родитель
Сommit
85d425e847

+ 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 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) {
                 val item = items[i]