Horis 2 лет назад
Родитель
Сommit
6f7b74b0a7

+ 5 - 3
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<TextPage>()
     private val textPages = arrayListOf<TextPage>()
     val pages: List<TextPage> get() = textPages
     val pages: List<TextPage> get() = textPages
 
 
-    var layout: TextChapterLayout? = null
+    private var layout: TextChapterLayout? = null
 
 
     fun getPage(index: Int): TextPage? {
     fun getPage(index: Int): TextPage? {
         return pages.getOrNull(index)
         return pages.getOrNull(index)
@@ -254,7 +254,9 @@ data class TextChapter(
     }
     }
 
 
     fun createLayout(scope: CoroutineScope, book: Book, bookContent: BookContent) {
     fun createLayout(scope: CoroutineScope, book: Book, bookContent: BookContent) {
-        textPages.clear()
+        if (layout != null) {
+            throw IllegalStateException("已经排版过了")
+        }
         layout = TextChapterLayout(
         layout = TextChapterLayout(
             scope,
             scope,
             this,
             this,
@@ -266,7 +268,7 @@ data class TextChapter(
 
 
     fun setProgressListener(l: LayoutProgressListener) {
     fun setProgressListener(l: LayoutProgressListener) {
         if (isCompleted) {
         if (isCompleted) {
-            l.onLayoutCompleted()
+            // no op
         } else if (layout?.exception != null) {
         } else if (layout?.exception != null) {
             l.onLayoutException(layout?.exception!!)
             l.onLayoutException(layout?.exception!!)
         } else {
         } else {

+ 1 - 1
app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt

@@ -93,7 +93,7 @@ class TextChapterLayout(
     fun setProgressListener(l: LayoutProgressListener) {
     fun setProgressListener(l: LayoutProgressListener) {
         try {
         try {
             if (isCompleted) {
             if (isCompleted) {
-                l.onLayoutCompleted()
+                // no op
             } else if (exception != null) {
             } else if (exception != null) {
                 l.onLayoutException(exception!!)
                 l.onLayoutException(exception!!)
             } else {
             } else {