From 7737089ee4072134c6f1f81f01578186831d508d Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 21 Feb 2020 19:28:11 +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 --- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 14 +++++++++++--- .../io/legado/app/ui/book/read/page/ContentView.kt | 8 ++++++++ .../io/legado/app/ui/book/read/page/PageView.kt | 8 ++++++++ 3 files changed, 27 insertions(+), 3 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 c46bd86ea..248f2b5e5 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 @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read +import android.annotation.SuppressLint import android.app.Activity import android.content.Intent import android.net.Uri @@ -312,9 +313,16 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo /** * view触摸 */ - override fun onTouch(v: View?, event: MotionEvent?): Boolean { - - + @SuppressLint("ClickableViewAccessibility") + override fun onTouch(v: View, event: MotionEvent): Boolean { + when (event.action) { + 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) + } + } + } return true } 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 a4e2b5b75..aedf2e8b9 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 @@ -121,6 +121,14 @@ class ContentView : FrameLayout { return selectPoint } + fun selectStartMove(x: Float, y: Float) { + + } + + fun selectEndMove(x: Float, y: Float) { + + } + fun scrollTo(pos: Int?) { if (pos != null) { content_text_view.post { 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 fe478f36c..13a3322d2 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 @@ -184,6 +184,14 @@ class PageView(context: Context, attrs: AttributeSet) : nextPage.upBattery(battery) } + fun selectStartMove(x: Float, y: Float) { + curPage.selectStartMove(x, y) + } + + fun selectEndMove(x: Float, y: Float) { + curPage.selectEndMove(x, y) + } + override val isScrollDelegate: Boolean get() = pageDelegate is ScrollPageDelegate