From d32f1f37ca6c7875f601371b92acbedf199ceb80 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Thu, 22 Feb 2024 08:30:26 +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 --- .../legado/app/ui/book/read/page/entities/TextChapter.kt | 8 +++++--- .../app/ui/book/read/page/provider/TextChapterLayout.kt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChapter.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChapter.kt index 7ba6da2ff..1b899facd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChapter.kt @@ -33,7 +33,7 @@ data class TextChapter( private val textPages = arrayListOf() val pages: List get() = textPages - var layout: TextChapterLayout? = null + private var layout: TextChapterLayout? = null fun getPage(index: Int): TextPage? { return pages.getOrNull(index) @@ -254,7 +254,9 @@ data class TextChapter( } fun createLayout(scope: CoroutineScope, book: Book, bookContent: BookContent) { - textPages.clear() + if (layout != null) { + throw IllegalStateException("已经排版过了") + } layout = TextChapterLayout( scope, this, @@ -266,7 +268,7 @@ data class TextChapter( fun setProgressListener(l: LayoutProgressListener) { if (isCompleted) { - l.onLayoutCompleted() + // no op } else if (layout?.exception != null) { l.onLayoutException(layout?.exception!!) } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt index 70d9028a3..02d20cb80 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt @@ -93,7 +93,7 @@ class TextChapterLayout( fun setProgressListener(l: LayoutProgressListener) { try { if (isCompleted) { - l.onLayoutCompleted() + // no op } else if (exception != null) { l.onLayoutException(exception!!) } else {