优化
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user