|
|
@ -278,7 +278,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
selectLineStart = lineIndex |
|
|
|
selectLineStart = lineIndex |
|
|
|
selectCharStart = charIndex |
|
|
|
selectCharStart = charIndex |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -299,7 +299,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
selectLineStart = lineIndex |
|
|
|
selectLineStart = lineIndex |
|
|
|
selectCharStart = charIndex |
|
|
|
selectCharStart = charIndex |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -318,7 +318,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
selectLineStart = lineIndex |
|
|
|
selectLineStart = lineIndex |
|
|
|
selectCharStart = charIndex |
|
|
|
selectCharStart = charIndex |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -342,7 +342,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
selectLineEnd = lineIndex |
|
|
|
selectLineEnd = lineIndex |
|
|
|
selectCharEnd = charIndex |
|
|
|
selectCharEnd = charIndex |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -362,7 +362,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
selectLineEnd = lineIndex |
|
|
|
selectLineEnd = lineIndex |
|
|
|
selectCharEnd = charIndex |
|
|
|
selectCharEnd = charIndex |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -380,7 +380,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
selectLineEnd = lineIndex |
|
|
|
selectLineEnd = lineIndex |
|
|
|
selectCharEnd = charIndex |
|
|
|
selectCharEnd = charIndex |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -390,6 +390,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 选择开始文字 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun selectStartMoveIndex(relativePage: Int, lineIndex: Int, charIndex: Int) { |
|
|
|
fun selectStartMoveIndex(relativePage: Int, lineIndex: Int, charIndex: Int) { |
|
|
|
selectPageStart = relativePage |
|
|
|
selectPageStart = relativePage |
|
|
|
selectLineStart = lineIndex |
|
|
|
selectLineStart = lineIndex |
|
|
@ -397,9 +400,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
val textLine = relativePage(relativePage).textLines[lineIndex] |
|
|
|
val textLine = relativePage(relativePage).textLines[lineIndex] |
|
|
|
val textChar = textLine.textChars[charIndex] |
|
|
|
val textChar = textLine.textChars[charIndex] |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset(relativePage)) |
|
|
|
upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset(relativePage)) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 选择结束文字 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun selectEndMoveIndex(relativePage: Int, lineIndex: Int, charIndex: Int) { |
|
|
|
fun selectEndMoveIndex(relativePage: Int, lineIndex: Int, charIndex: Int) { |
|
|
|
selectPageEnd = relativePage |
|
|
|
selectPageEnd = relativePage |
|
|
|
selectLineEnd = lineIndex |
|
|
|
selectLineEnd = lineIndex |
|
|
@ -407,21 +413,34 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
val textLine = relativePage(relativePage).textLines[lineIndex] |
|
|
|
val textLine = relativePage(relativePage).textLines[lineIndex] |
|
|
|
val textChar = textLine.textChars[charIndex] |
|
|
|
val textChar = textLine.textChars[charIndex] |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset(relativePage)) |
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset(relativePage)) |
|
|
|
upSelectChars(textPage) |
|
|
|
upSelectChars() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upSelectChars(textPage: TextPage) { |
|
|
|
private fun upSelectChars() { |
|
|
|
for ((lineIndex, textLine) in textPage.textLines.withIndex()) { |
|
|
|
val last = if (ReadBookConfig.isScroll) 2 else 0 |
|
|
|
|
|
|
|
for (relativePos in 0..last) { |
|
|
|
|
|
|
|
for ((lineIndex, textLine) in relativePage(relativePos).textLines.withIndex()) { |
|
|
|
for ((charIndex, textChar) in textLine.textChars.withIndex()) { |
|
|
|
for ((charIndex, textChar) in textLine.textChars.withIndex()) { |
|
|
|
textChar.selected = |
|
|
|
textChar.selected = |
|
|
|
if (lineIndex == selectLineStart && lineIndex == selectLineEnd) { |
|
|
|
if (relativePos == selectPageStart |
|
|
|
|
|
|
|
&& relativePos == selectPageEnd |
|
|
|
|
|
|
|
&& lineIndex == selectLineStart |
|
|
|
|
|
|
|
&& lineIndex == selectLineEnd |
|
|
|
|
|
|
|
) { |
|
|
|
charIndex in selectCharStart..selectCharEnd |
|
|
|
charIndex in selectCharStart..selectCharEnd |
|
|
|
} else if (lineIndex == selectLineStart) { |
|
|
|
} else if (relativePos == selectPageStart && lineIndex == selectLineStart) { |
|
|
|
charIndex >= selectCharStart |
|
|
|
charIndex >= selectCharStart |
|
|
|
} else if (lineIndex == selectLineEnd) { |
|
|
|
} else if (relativePos == selectPageEnd && lineIndex == selectLineEnd) { |
|
|
|
charIndex <= selectCharEnd |
|
|
|
charIndex <= selectCharEnd |
|
|
|
} else { |
|
|
|
} else if (relativePos == selectPageStart && relativePos == selectPageEnd) { |
|
|
|
lineIndex in (selectLineStart + 1) until selectLineEnd |
|
|
|
lineIndex in (selectLineStart + 1) until selectLineEnd |
|
|
|
|
|
|
|
} else if (relativePos == selectPageStart) { |
|
|
|
|
|
|
|
lineIndex > selectLineStart |
|
|
|
|
|
|
|
} else if (relativePos == selectPageEnd) { |
|
|
|
|
|
|
|
lineIndex < selectLineEnd |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
relativePos in selectPageStart + 1 until selectPageEnd |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|