From d30235043d2a6b29cc01986c757710e573da4166 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 22 Feb 2020 09:53:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 24 +++++++------------ .../app/ui/book/read/page/ContentView.kt | 11 ++------- .../legado/app/ui/book/read/page/PageView.kt | 4 ---- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 688a24bb2..1faba90fd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -317,24 +317,16 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo @SuppressLint("ClickableViewAccessibility") override fun onTouch(v: View, event: MotionEvent): Boolean { when (event.action) { - MotionEvent.ACTION_DOWN -> { - when (v.id) { - R.id.cursor_left -> { - val startX = v.x + 10.dp - val startY = v.y - 10.dp - page_view.setSelectMoveStart(startX, startY) - } - R.id.cursor_right -> { - val startX = v.x - 10.dp - val startY = v.y - 10.dp - page_view.setSelectMoveStart(startX, startY) - } - } - } MotionEvent.ACTION_MOVE, MotionEvent.ACTION_UP -> { when (v.id) { - R.id.cursor_left -> page_view.selectStartMove(event.x, event.y) - R.id.cursor_right -> page_view.selectEndMove(event.x, event.y) + R.id.cursor_left -> page_view.selectStartMove( + event.rawX + cursor_left.width, + event.rawY - cursor_left.height + ) + R.id.cursor_right -> page_view.selectEndMove( + event.rawX - cursor_right.width, + event.rawY - cursor_right.height + ) } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index bf617a639..be24f5714 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -18,8 +18,6 @@ import java.util.* class ContentView(context: Context) : FrameLayout(context) { var callBack: CallBack? = null private var pageSize: Int = 0 - private var textSelectMoveStartX = 0f - private var textSelectMoveStartY = 0f init { //设置背景防止切换背景时文字重叠 @@ -111,17 +109,12 @@ class ContentView(context: Context) : FrameLayout(context) { return content_text_view.selectText(e.x, y) } - fun setSelectMoveStart(x: Float, y: Float) { - textSelectMoveStartX = x - textSelectMoveStartY = y - content_text_view.headerHeight - } - fun selectStartMove(x: Float, y: Float) { - content_text_view.selectStartMove(textSelectMoveStartX + x, textSelectMoveStartY + y) + content_text_view.selectStartMove(x, y - content_text_view.headerHeight) } fun selectEndMove(x: Float, y: Float) { - content_text_view.selectEndMove(textSelectMoveStartX + x, textSelectMoveStartY + y) + content_text_view.selectEndMove(x, y - content_text_view.headerHeight) } fun cancelSelect() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index f2bdd54d6..dbb7167f0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -183,10 +183,6 @@ class PageView(context: Context, attrs: AttributeSet) : nextPage.upBattery(battery) } - fun setSelectMoveStart(x: Float, y: Float) { - curPage.setSelectMoveStart(x, y) - } - fun selectStartMove(x: Float, y: Float) { curPage.selectStartMove(x, y) }