From 0a88f1f6fd08d6e95a96111438ffb8d2b243b24d Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 21 Feb 2020 11:52:37 +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/PageView.kt | 4 ++ .../book/read/page/delegate/PageDelegate.kt | 37 ++++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) 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 867341e82..a0a5c36d3 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 @@ -132,6 +132,8 @@ class PageView(context: Context, attrs: AttributeSet) : } else { fillPage(PageDelegate.Direction.PREV) } + } else { + pageDelegate?.start(PageDelegate.Direction.PREV) } } @@ -144,6 +146,8 @@ class PageView(context: Context, attrs: AttributeSet) : } else { fillPage(PageDelegate.Direction.NEXT) } + } else { + pageDelegate?.start(PageDelegate.Direction.NEXT) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index ed32732aa..89c186679 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -179,23 +179,6 @@ abstract class PageDelegate(protected val pageView: PageView) { onScrollStart() } - /** - * 触摸事件处理 - */ - @CallSuper - open fun onTouch(event: MotionEvent): Boolean { - if (isStarted) return false - curPage.dispatchTouchEvent(event) - if (event.action == MotionEvent.ACTION_UP) { - if (isMoved) { - // 开启翻页效果 - if (!noNext) onScrollStart() - return true - } - } - return detector.onTouchEvent(event) - } - abstract fun onScrollStart()//scroller start abstract fun onDraw(canvas: Canvas)//绘制 @@ -229,6 +212,16 @@ abstract class PageDelegate(protected val pageView: PageView) { } } + /** + * 触摸事件处理 + */ + @CallSuper + open fun onTouch(event: MotionEvent): Boolean { + if (isStarted) return false + curPage.dispatchTouchEvent(event) + return detector.onTouchEvent(event) + } + /** * 触摸事件处理 */ @@ -288,6 +281,16 @@ abstract class PageDelegate(protected val pageView: PageView) { ): Boolean { return this@PageDelegate.onScroll(e1, e2, distanceX, distanceY) } + + override fun onFling( + e1: MotionEvent?, + e2: MotionEvent?, + velocityX: Float, + velocityY: Float + ): Boolean { + if (!noNext) onScrollStart() + return true + } } fun hasPrev(): Boolean {