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) }