pull/357/head
gedoor 4 years ago
parent 267b5e1d83
commit 54ed40d23e
  1. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt

@ -5,6 +5,7 @@ import android.graphics.Canvas
import android.graphics.Paint import android.graphics.Paint
import android.graphics.RectF import android.graphics.RectF
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log
import android.view.View import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
@ -297,10 +298,13 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (!ReadBookConfig.isScroll) return if (!ReadBookConfig.isScroll) return
if (relativeOffset >= ChapterProvider.visibleHeight) return if (relativeOffset >= ChapterProvider.visibleHeight) return
} }
Log.e("y", "$y")
for ((lineIndex, textLine) in relativePage(relativePos).textLines.withIndex()) { for ((lineIndex, textLine) in relativePage(relativePos).textLines.withIndex()) {
if (y > textLine.lineTop + relativeOffset && y < textLine.lineBottom + relativeOffset) { if (y > textLine.lineTop + relativeOffset && y < textLine.lineBottom + relativeOffset) {
Log.e("line", "$relativePos $lineIndex")
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) {
Log.e("char", "$relativePos $lineIndex $charIndex")
if (selectEnd[0] != relativePos || selectEnd[1] != lineIndex || selectEnd[2] != charIndex) { if (selectEnd[0] != relativePos || selectEnd[1] != lineIndex || selectEnd[2] != charIndex) {
if (selectToInt(relativePos, lineIndex, charIndex) < selectToInt(selectStart)) { if (selectToInt(relativePos, lineIndex, charIndex) < selectToInt(selectStart)) {
return return
@ -462,11 +466,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
} }
private fun selectToInt(page: Int, line: Int, char: Int): Int { private fun selectToInt(page: Int, line: Int, char: Int): Int {
return page * 1000000 + line * 100000 + char return page * 10000000 + line * 100000 + char
} }
private fun selectToInt(select: Array<Int>): Int { private fun selectToInt(select: Array<Int>): Int {
return select[0] * 1000000 + select[1] * 100000 + select[2] return select[0] * 10000000 + select[1] * 100000 + select[2]
} }
private fun relativeOffset(relativePos: Int): Float { private fun relativeOffset(relativePos: Int): Float {

Loading…
Cancel
Save