feat: 优化代码

pull/111/head
kunfei 5 years ago
parent d30235043d
commit b725dc1bd3
  1. 13
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt

@ -165,15 +165,16 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
private fun upSelectChars(textPage: TextPage) { private fun upSelectChars(textPage: TextPage) {
for ((lineIndex, textLine) in textPage.textLines.withIndex()) { for ((lineIndex, textLine) in textPage.textLines.withIndex()) {
for ((charIndex, textChar) in textLine.textChars.withIndex()) { for ((charIndex, textChar) in textLine.textChars.withIndex()) {
textChar.selected = when (lineIndex) { textChar.selected =
selectStartLine -> { if (lineIndex == selectStartLine && lineIndex == selectEndLine) {
charIndex in selectStartChar..selectEndChar
} else if (lineIndex == selectStartLine) {
charIndex >= selectStartChar charIndex >= selectStartChar
} } else if (lineIndex == selectEndLine) {
selectEndLine -> {
charIndex <= selectEndChar charIndex <= selectEndChar
} else {
lineIndex in (selectStartLine + 1) until selectEndLine
} }
else -> lineIndex in (selectStartLine + 1) until selectEndLine
}
} }
} }
invalidate() invalidate()

Loading…
Cancel
Save