From b02e95fa073cee783a57df8736b9617ef3456687 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:18:39 +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/TextPage.kt | 3 ++- .../ui/book/read/page/provider/TextChapterLayout.kt | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index ebccb46ec..dd54316b7 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -326,7 +326,8 @@ data class TextPage( fun render(view: ContentTextView): Boolean { if (!isCompleted) return false - return canvasRecorder.recordIfNeeded(view.width, height.toInt() + paddingTop) { + val height = lines.lastOrNull()?.lineBottom?.toInt() ?: 0 + return canvasRecorder.recordIfNeeded(view.width, height) { drawPage(view, this) } } 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 211c54269..f4b9d1ee4 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 @@ -33,7 +33,6 @@ import kotlinx.coroutines.launch import java.util.LinkedList import java.util.Locale import kotlin.coroutines.coroutineContext -import kotlin.math.max import kotlin.math.roundToInt class TextChapterLayout( @@ -447,9 +446,8 @@ class TextChapterLayout( val textLine = TextLine(isTitle = isTitle) if (durY + textHeight > visibleHeight) { val textPage = pendingTextPage - val height = max(durY, textPage.lines.lastOrNull()?.lineBottom ?: 0f) - if (textPage.height < height) { - textPage.height = height + if (textPage.height < durY) { + textPage.height = durY } if (doublePage && absStartX < viewWidth / 2) { //当前页面左列结束 @@ -532,9 +530,8 @@ class TextChapterLayout( val textPage = pendingTextPage textPage.addLine(textLine) durY += textHeight * lineSpacingExtra - val height = max(durY, textPage.lines.lastOrNull()?.lineBottom ?: 0f) - if (textPage.height < height) { - textPage.height = height + if (textPage.height < durY) { + textPage.height = durY } } durY += textHeight * paragraphSpacing / 10f