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 {