From 3c8def787d4859fc15749d6879140c4c8277e1c2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 24 Feb 2020 12:07:36 +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 --- .../legado/app/ui/book/read/page/ContentTextView.kt | 2 -- .../io/legado/app/ui/book/read/page/ContentView.kt | 4 ++++ .../io/legado/app/ui/book/read/page/PageView.kt | 1 + .../book/read/page/delegate/ScrollPageDelegate.kt | 13 ++++++++----- 4 files changed, 13 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 752927c51..dfaa208ba 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 @@ -35,7 +35,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private val maxScrollOffset = 100f private var pageOffset = 0f private var linePos = 0 - private var isLastPage = false init { callBack = activity as CallBack @@ -163,7 +162,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at fun resetPageOffset() { pageOffset = 0f linePos = 0 - isLastPage = false } fun selectText(x: Float, y: Float): Boolean { 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 5c387ac92..d6ae6eb3a 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 @@ -111,6 +111,10 @@ class ContentView(context: Context) : FrameLayout(context) { content_text_view.onScroll(offset) } + fun resetPageOffset() { + content_text_view.resetPageOffset() + } + fun upSelectAble(selectAble: Boolean) { content_text_view.selectAble = selectAble } 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 ac7671406..4b5ee7dbd 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 @@ -100,6 +100,7 @@ class PageView(context: Context, attrs: AttributeSet) : fun upContent(position: Int = 0) { if (ReadBookConfig.isScroll) { + curPage.resetPageOffset() curPage.setContent(pageFactory.currentPage) } else { when (position) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt index 714c26f89..c9e097808 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt @@ -31,11 +31,14 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) { } } - override fun onDown(e: MotionEvent): Boolean { - abort() - mVelocity.clear() - mVelocity.addMovement(e) - return super.onDown(e) + override fun onTouch(event: MotionEvent): Boolean { + if (event.action == MotionEvent.ACTION_DOWN) { + setStartPoint(event.x, event.y) + abort() + mVelocity.clear() + mVelocity.addMovement(event) + } + return super.onTouch(event) } override fun onScroll(