From a3a86fb0442a71bf1a71bc0635dc8fee69d83aba Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 23 Sep 2019 08:49:11 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/widget/page/delegate/PageDelegate.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt index b83e4bc88..9ce140145 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt @@ -94,7 +94,7 @@ abstract class PageDelegate(protected val pageView: PageView) { startY, dx, dy, - getDuration((if (dx != 0) dx else dy).toFloat()) + if (dx != 0) getDuration(dx, viewWidth) else getDuration(dy, viewHeight) ) isRunning = true isStarted = true @@ -109,9 +109,8 @@ abstract class PageDelegate(protected val pageView: PageView) { invalidate() } - protected fun getDuration(distance: Float): Int { - val duration = 300 * abs(distance) / viewWidth - return duration.toInt() + private fun getDuration(distance: Int, len: Int): Int { + return (300f * abs(distance) / len).toInt() } fun setViewSize(width: Int, height: Int) {