From ed2ab8e2c1b9b4e4475fb93393679dd2e6510cdd Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 61e990875564..aefd5514cebb 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -51,6 +51,7 @@ import java.io.File import java.io.FileInputStream import java.io.FileNotFoundException import java.io.FileOutputStream +import kotlin.math.max /** * 阅读界面数据处理 @@ -113,8 +114,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { return } ReadBook.upMsg(null) - if (ReadBook.durChapterIndex > ReadBook.simulatedChapterSize - 1) { - ReadBook.durChapterIndex = ReadBook.simulatedChapterSize - 1 + val maxChapterSize = max(0, ReadBook.simulatedChapterSize - 1) + if (ReadBook.durChapterIndex > maxChapterSize) { + ReadBook.durChapterIndex = maxChapterSize } if (!isSameBook) { ReadBook.loadContent(resetPageOffset = true)