From 3109357326c65cea12f03676252e4907f905d0dd Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 9 Nov 2019 17:38:16 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt b/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt index 0ab136b42..b6e18a834 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.widget.page import android.text.SpannableStringBuilder +import kotlin.math.min data class TextChapter( val position: Int, @@ -53,7 +54,8 @@ data class TextChapter( fun getReadLength(pageIndex: Int): Int { var length = 0 - for (index in 0 until pageIndex) { + val maxIndex = min(pageIndex, pageLines.lastIndex) + for (index in 0 until maxIndex) { length += pageLengths[index] } return length