From 3a806b5b3b659e0d0b6a51f17d39ddc6d5a68127 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 Apr 2022 14:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ContentTextView.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 13f5f42f9..729329a4c 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 @@ -454,13 +454,15 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } fun compare(pos: Pos): Int { - if (relativePos < pos.relativePos) return -3 - if (relativePos > pos.relativePos) return 3 - if (lineIndex < pos.lineIndex) return -2 - if (lineIndex > pos.lineIndex) return 2 - if (charIndex < pos.charIndex) return -1 - if (charIndex > pos.charIndex) return 1 - return 0 + return when { + relativePos < pos.relativePos -> -3 + relativePos > pos.relativePos -> 3 + lineIndex < pos.lineIndex -> -2 + lineIndex > pos.lineIndex -> 2 + charIndex < pos.charIndex -> -1 + charIndex > pos.charIndex -> 1 + else -> 0 + } } }