From 274ddede3302853c1b2bafaeccda6a62239f2e4b Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 3 Aug 2020 22:40:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../read/page/delegate/CoverPageDelegate.kt | 4 ++-- .../page/delegate/HorizontalPageDelegate.kt | 8 +++---- .../read/page/delegate/NoAnimPageDelegate.kt | 2 +- .../book/read/page/delegate/PageDelegate.kt | 22 +++++++++---------- .../read/page/delegate/ScrollPageDelegate.kt | 10 ++++----- .../page/delegate/SimulationPageDelegate.kt | 4 ++-- .../read/page/delegate/SlidePageDelegate.kt | 4 ++-- 7 files changed, 27 insertions(+), 27 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 05437cd70..278b8fffc 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 @@ -57,7 +57,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { } } - override fun onAnimStart() { + override fun onAnimStart(animationSpeed: Int) { val distanceX: Float when (mDirection) { Direction.NEXT -> distanceX = @@ -77,7 +77,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { viewWidth - (touchX - startX) } } - startScroll(touchX.toInt(), 0, distanceX.toInt(), 0) + startScroll(touchX.toInt(), 0, distanceX.toInt(), 0, animationSpeed) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt index 774f522be..b6f4b282f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt @@ -103,20 +103,20 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie } } - override fun nextPageByAnim() { + override fun nextPageByAnim(animationSpeed: Int) { abort() if (!hasNext()) return setDirection(Direction.NEXT) setTouchPoint(viewWidth.toFloat(), 0f) - onAnimStart() + onAnimStart(animationSpeed) } - override fun prevPageByAnim() { + override fun prevPageByAnim(animationSpeed: Int) { abort() if (!hasPrev()) return setDirection(Direction.PREV) setTouchPoint(0f, 0f) - onAnimStart() + onAnimStart(animationSpeed) } override fun onDestroy() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt index cacb9d87d..b0c196ccd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt @@ -5,7 +5,7 @@ import io.legado.app.ui.book.read.page.PageView class NoAnimPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { - override fun onAnimStart() { + override fun onAnimStart(animationSpeed: Int) { if (!isCancel) { pageView.fillPage(mDirection) } 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 914420fe2..19ec4b76d 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 @@ -24,7 +24,7 @@ abstract class PageDelegate(protected val pageView: PageView) : pageView.width * 0.66f, pageView.height * 0.66f ) protected val context: Context = pageView.context - private val animationSpeed = 300 + private val defaultAnimationSpeed = 300 //起始点 protected var startX: Float = 0f @@ -115,7 +115,7 @@ abstract class PageDelegate(protected val pageView: PageView) : pageView.invalidate() } - protected fun startScroll(startX: Int, startY: Int, dx: Int, dy: Int) { + protected fun startScroll(startX: Int, startY: Int, dx: Int, dy: Int, animationSpeed: Int) { val duration = if (dx != 0) { (animationSpeed * abs(dx)) / viewWidth } else { @@ -163,7 +163,7 @@ abstract class PageDelegate(protected val pageView: PageView) : return false } - open fun onAnimStart() {}//scroller start + open fun onAnimStart(animationSpeed: Int) {}//scroller start open fun onDraw(canvas: Canvas) {}//绘制 @@ -171,15 +171,15 @@ abstract class PageDelegate(protected val pageView: PageView) : open fun onScroll() {}//移动contentView, slidePage - abstract fun nextPageByAnim() + abstract fun nextPageByAnim(animationSpeed: Int) - abstract fun prevPageByAnim() + abstract fun prevPageByAnim(animationSpeed: Int) open fun keyTurnPage(direction: Direction) { if (isRunning) return when (direction) { - Direction.NEXT -> nextPageByAnim() - Direction.PREV -> prevPageByAnim() + Direction.NEXT -> nextPageByAnim(100) + Direction.PREV -> prevPageByAnim(100) else -> return } } @@ -207,7 +207,7 @@ abstract class PageDelegate(protected val pageView: PageView) : if (selectedOnDown) { selectedOnDown = false } - if (!noNext) onAnimStart() + if (!noNext) onAnimStart(defaultAnimationSpeed) } } } @@ -247,7 +247,7 @@ abstract class PageDelegate(protected val pageView: PageView) : return true } if (isMoved) { - if (!noNext) onAnimStart() + if (!noNext) onAnimStart(defaultAnimationSpeed) return true } val x = e.x @@ -259,9 +259,9 @@ abstract class PageDelegate(protected val pageView: PageView) : if (x > viewWidth / 2 || AppConfig.clickAllNext ) { - nextPageByAnim() + nextPageByAnim(defaultAnimationSpeed) } else { - prevPageByAnim() + prevPageByAnim(defaultAnimationSpeed) } } return true 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 5765577bd..b707388fe 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 @@ -12,7 +12,7 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) { //速度追踪器 private val mVelocity: VelocityTracker = VelocityTracker.obtain() - override fun onAnimStart() { + override fun onAnimStart(animationSpeed: Int) { //惯性滚动 fling( 0, touchY.toInt(), 0, mVelocity.yVelocity.toInt(), @@ -78,13 +78,13 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) { mVelocity.recycle() } - override fun nextPageByAnim() { + override fun nextPageByAnim(animationSpeed: Int) { abort() - startScroll(0, 0, 0, -ChapterProvider.visibleHeight) + startScroll(0, 0, 0, -ChapterProvider.visibleHeight, animationSpeed) } - override fun prevPageByAnim() { + override fun prevPageByAnim(animationSpeed: Int) { abort() - startScroll(0, 0, 0, ChapterProvider.visibleHeight) + startScroll(0, 0, 0, ChapterProvider.visibleHeight, animationSpeed) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index 616a41614..9f217f5a5 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -154,7 +154,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi } } - override fun onAnimStart() { + override fun onAnimStart(animationSpeed: Int) { var dx: Float val dy: Float // dy 垂直方向滑动的距离,负值会使滚动向上滚动 @@ -184,7 +184,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi (1 - touchY) // 防止mTouchY最终变为0 } } - startScroll(touchX.toInt(), touchY.toInt(), dx.toInt(), dy.toInt()) + startScroll(touchX.toInt(), touchY.toInt(), dx.toInt(), dy.toInt(), animationSpeed) } override fun onAnimStop() { 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 197b65c39..9c3413f6a 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 @@ -8,7 +8,7 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { private val bitmapMatrix = Matrix() - override fun onAnimStart() { + override fun onAnimStart(animationSpeed: Int) { val distanceX: Float when (mDirection) { Direction.NEXT -> distanceX = @@ -28,7 +28,7 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { viewWidth - (touchX - startX) } } - startScroll(touchX.toInt(), 0, distanceX.toInt(), 0) + startScroll(touchX.toInt(), 0, distanceX.toInt(), 0, animationSpeed) } override fun onDraw(canvas: Canvas) {