From 08c6b9a0b254ea4c3734274ddd3241fb06b5df96 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 Apr 2022 11:19:21 +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 --- .../io/legado/app/ui/book/read/page/ContentTextView.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index bfeb3252d..68bd01393 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -347,9 +347,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at val last = if (callBack.isScroll) 2 else 0 val charPos = Pos(0, 0, 0) for (relativePos in 0..last) { + charPos.relativePos = relativePos for ((lineIndex, textLine) in relativePage(relativePos).textLines.withIndex()) { + charPos.lineIndex = lineIndex for ((charIndex, textChar) in textLine.textChars.withIndex()) { - charPos.upData(relativePos, lineIndex, charIndex) + charPos.charIndex = charIndex textChar.selected = charPos.compare(selectStart) >= 0 && charPos.compare(selectEnd) <= 0 textChar.isSearchResult = textChar.selected && callBack.isSelectingSearchResult @@ -447,12 +449,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at var charIndex: Int ) { - fun upData(relativePos: Int, lineIndex: Int, charIndex: Int) { - this.relativePos = relativePos - this.lineIndex = lineIndex - this.charIndex = charIndex - } - fun upData(pos: Pos) { relativePos = pos.relativePos lineIndex = pos.lineIndex