优化翻页

pull/357/head
gedoor 4 years ago
parent 32112e8efa
commit e118a309b1
  1. 52
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -226,16 +226,15 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (y > textLine.lineTop + relativeOffset && y < textLine.lineBottom + relativeOffset) { if (y > textLine.lineTop + relativeOffset && y < textLine.lineBottom + relativeOffset) {
for ((charIndex, textChar) in textLine.textChars.withIndex()) { for ((charIndex, textChar) in textLine.textChars.withIndex()) {
if (x > textChar.start && x < textChar.end) { if (x > textChar.start && x < textChar.end) {
initSelect( if (textChar.isImage) {
page.chapterIndex, activity?.supportFragmentManager?.let {
relativePos, PhotoDialog.show(it, page.chapterIndex, textChar.charData)
textLine, }
textChar, } else {
lineIndex, textChar.selected = true
charIndex, invalidate()
relativeOffset, select(relativePos, lineIndex, charIndex)
select }
)
return 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)
}
}
/** /**
* 开始选择符移动 * 开始选择符移动
*/ */

@ -219,6 +219,8 @@ class PageView(context: Context, attrs: AttributeSet) :
firstRelativePage = relativePage firstRelativePage = relativePage
firstLineIndex = lineIndex firstLineIndex = lineIndex
firstCharIndex = charIndex firstCharIndex = charIndex
curPage.selectStartMoveIndex(firstRelativePage, firstLineIndex, firstCharIndex)
curPage.selectEndMoveIndex(firstRelativePage, firstLineIndex, firstCharIndex)
} }
} }

Loading…
Cancel
Save