Horis 1 год назад
Родитель
Сommit
d6f7ba7c90

+ 11 - 0
app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt

@@ -20,6 +20,8 @@ import io.legado.app.utils.canvasrecorder.recordIfNeeded
 import io.legado.app.utils.dpToPx
 import splitties.init.appCtx
 import java.text.DecimalFormat
+import kotlin.math.ceil
+import kotlin.math.max
 import kotlin.math.min
 
 /**
@@ -178,6 +180,7 @@ data class TextPage(
                 addLine(textLine)
             }
             height = ChapterProvider.visibleHeight.toFloat()
+            upRenderHeight()
             invalidate()
             isCompleted = true
         }
@@ -359,4 +362,12 @@ data class TextPage(
     fun hasImageOrEmpty(): Boolean {
         return textLines.any { it.isImage } || textLines.isEmpty()
     }
+
+    fun upRenderHeight() {
+        renderHeight = ceil(lines.last().lineBottom).toInt()
+        if (leftLineSize > 0 && leftLineSize != lines.size) {
+            val leftHeight = ceil(lines[leftLineSize - 1].lineBottom).toInt()
+            renderHeight = max(renderHeight, leftHeight)
+        }
+    }
 }

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

@@ -131,7 +131,7 @@ class TextChapterLayout(
 
     private fun onPageCompleted() {
         val textPage = pendingTextPage
-        textPage.index = textPages.lastIndex
+        textPage.index = textPages.size
         textPage.chapterIndex = bookChapter.index
         textPage.chapterSize = chaptersSize
         textPage.title = displayTitle
@@ -140,7 +140,7 @@ class TextChapterLayout(
         textPage.isCompleted = true
         textPage.textChapter = textChapter
         textPage.upLinesPosition()
-        textPage.renderHeight = textPage.lines.maxOf { it.lineBottom.toInt() }
+        textPage.upRenderHeight()
         textPages.add(textPage)
         channel.trySend(textPage)
         try {