修复可能出现的崩溃问题
This commit is contained in:
1 file changed
+8
-3
@@ -291,10 +291,10 @@ data class TextPage(
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
fun containPos(chapterPos: Int): Boolean {
|
fun containPos(chapterPos: Int): Boolean {
|
||||||
val line = lines.first()
|
val line = lines.firstOrNull() ?: return false // lines 为空时直接返回 false
|
||||||
val startPos = line.chapterPosition
|
val startPos = line.chapterPosition
|
||||||
val endPos = startPos + charSize
|
val endPos = startPos + charSize
|
||||||
return chapterPos in startPos..<endPos
|
return chapterPos in startPos until endPos
|
||||||
}
|
}
|
||||||
|
|
||||||
fun draw(view: ContentTextView, canvas: Canvas, relativeOffset: Float) {
|
fun draw(view: ContentTextView, canvas: Canvas, relativeOffset: Float) {
|
||||||
@@ -364,10 +364,15 @@ data class TextPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun upRenderHeight() {
|
fun upRenderHeight() {
|
||||||
|
if (lines.isEmpty()) {
|
||||||
|
renderHeight = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
renderHeight = ceil(lines.last().lineBottom).toInt()
|
renderHeight = ceil(lines.last().lineBottom).toInt()
|
||||||
if (leftLineSize > 0 && leftLineSize != lines.size) {
|
if (leftLineSize > 0 && leftLineSize <= lines.size) {
|
||||||
val leftHeight = ceil(lines[leftLineSize - 1].lineBottom).toInt()
|
val leftHeight = ceil(lines[leftLineSize - 1].lineBottom).toInt()
|
||||||
renderHeight = max(renderHeight, leftHeight)
|
renderHeight = max(renderHeight, leftHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user