优化
This commit is contained in:
@@ -20,6 +20,8 @@ import io.legado.app.utils.canvasrecorder.recordIfNeeded
|
|||||||
import io.legado.app.utils.dpToPx
|
import io.legado.app.utils.dpToPx
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
import kotlin.math.ceil
|
||||||
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,6 +180,7 @@ data class TextPage(
|
|||||||
addLine(textLine)
|
addLine(textLine)
|
||||||
}
|
}
|
||||||
height = ChapterProvider.visibleHeight.toFloat()
|
height = ChapterProvider.visibleHeight.toFloat()
|
||||||
|
upRenderHeight()
|
||||||
invalidate()
|
invalidate()
|
||||||
isCompleted = true
|
isCompleted = true
|
||||||
}
|
}
|
||||||
@@ -359,4 +362,12 @@ data class TextPage(
|
|||||||
fun hasImageOrEmpty(): Boolean {
|
fun hasImageOrEmpty(): Boolean {
|
||||||
return textLines.any { it.isImage } || textLines.isEmpty()
|
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() {
|
private fun onPageCompleted() {
|
||||||
val textPage = pendingTextPage
|
val textPage = pendingTextPage
|
||||||
textPage.index = textPages.lastIndex
|
textPage.index = textPages.size
|
||||||
textPage.chapterIndex = bookChapter.index
|
textPage.chapterIndex = bookChapter.index
|
||||||
textPage.chapterSize = chaptersSize
|
textPage.chapterSize = chaptersSize
|
||||||
textPage.title = displayTitle
|
textPage.title = displayTitle
|
||||||
@@ -140,7 +140,7 @@ class TextChapterLayout(
|
|||||||
textPage.isCompleted = true
|
textPage.isCompleted = true
|
||||||
textPage.textChapter = textChapter
|
textPage.textChapter = textChapter
|
||||||
textPage.upLinesPosition()
|
textPage.upLinesPosition()
|
||||||
textPage.renderHeight = textPage.lines.maxOf { it.lineBottom.toInt() }
|
textPage.upRenderHeight()
|
||||||
textPages.add(textPage)
|
textPages.add(textPage)
|
||||||
channel.trySend(textPage)
|
channel.trySend(textPage)
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user