From 52c366da4fec87c6a3479a19fa3a6c8f9c2784b0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 2 Mar 2020 20:04:08 +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 --- .../read/page/delegate/CoverPageDelegate.kt | 51 +++++++++++-------- .../read/page/delegate/SlidePageDelegate.kt | 2 +- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt index c7d342213..7e73700e9 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt @@ -16,27 +16,11 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { shadowDrawableR.gradientType = GradientDrawable.LINEAR_GRADIENT } - override fun onAnimStart() { - val distanceX: Float - when (mDirection) { - Direction.NEXT -> distanceX = - if (isCancel) { - var dis = viewWidth - startX + touchX - if (dis > viewWidth) { - dis = viewWidth.toFloat() - } - viewWidth - dis - } else { - -(touchX + (viewWidth - startX)) - } - else -> distanceX = - if (isCancel) { - -(touchX - startX) - } else { - viewWidth - (touchX - startX) - } - } - startScroll(touchX.toInt(), 0, distanceX.toInt(), 0) + override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) { + curPage.x = 0.toFloat() + prevPage.x = -viewWidth.toFloat() + nextPage.x = 0.toFloat() + super.setStartPoint(x, y, invalidate) } override fun onDraw(canvas: Canvas) { @@ -47,7 +31,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { ) return val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth - if (!isMoved) return + if (!isRunning) return if (mDirection == Direction.PREV) { prevPage.translationX = offsetX - viewWidth } else if (mDirection == Direction.NEXT) { @@ -74,4 +58,27 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { } } + override fun onAnimStart() { + val distanceX: Float + when (mDirection) { + Direction.NEXT -> distanceX = + if (isCancel) { + var dis = viewWidth - startX + touchX + if (dis > viewWidth) { + dis = viewWidth.toFloat() + } + viewWidth - dis + } else { + -(touchX + (viewWidth - startX)) + } + else -> distanceX = + if (isCancel) { + -(touchX - startX) + } else { + viewWidth - (touchX - startX) + } + } + startScroll(touchX.toInt(), 0, distanceX.toInt(), 0) + } + } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt index ee325f099..850c6b4ea 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt @@ -42,7 +42,7 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { || (mDirection == Direction.PREV && offsetX < 0) ) return - if (!isMoved) return + if (!isRunning) return if (mDirection == Direction.PREV) { curPage.translationX = offsetX prevPage.translationX = offsetX - viewWidth