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 1a469b3ba..da57d224b 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 @@ -226,16 +226,15 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at if (y > textLine.lineTop + relativeOffset && y < textLine.lineBottom + relativeOffset) { for ((charIndex, textChar) in textLine.textChars.withIndex()) { if (x > textChar.start && x < textChar.end) { - initSelect( - page.chapterIndex, - relativePos, - textLine, - textChar, - lineIndex, - charIndex, - relativeOffset, - select - ) + if (textChar.isImage) { + activity?.supportFragmentManager?.let { + PhotoDialog.show(it, page.chapterIndex, textChar.charData) + } + } else { + textChar.selected = true + invalidate() + select(relativePos, lineIndex, charIndex) + } return } } @@ -247,39 +246,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } - private fun initSelect( - chapterIndex: Int, - relativePage: Int, - textLine: TextLine, - textChar: TextChar, - lineIndex: Int, - charIndex: Int, - relativeOffset: Float, - select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit, - ) { - if (textChar.isImage) { - activity?.supportFragmentManager?.let { - PhotoDialog.show(it, chapterIndex, textChar.charData) - } - } else { - textChar.selected = true - invalidate() - selectStart[0] = relativePage - selectStart[1] = lineIndex - selectStart[2] = charIndex - selectEnd[0] = relativePage - selectEnd[1] = lineIndex - selectEnd[2] = charIndex - upSelectedStart( - textChar.start, - textLine.lineBottom + relativeOffset, - textLine.lineTop + relativeOffset - ) - upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) - select(relativePage, lineIndex, charIndex) - } - } - /** * 开始选择符移动 */ diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 42f7311a7..b2871d38c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -219,6 +219,8 @@ class PageView(context: Context, attrs: AttributeSet) : firstRelativePage = relativePage firstLineIndex = lineIndex firstCharIndex = charIndex + curPage.selectStartMoveIndex(firstRelativePage, firstLineIndex, firstCharIndex) + curPage.selectEndMoveIndex(firstRelativePage, firstLineIndex, firstCharIndex) } }