diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt index 1dd027fd..cbcd1054 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -43,6 +43,9 @@ import com.pitchedapps.frost.web.FrostJSI import com.pitchedapps.frost.web.FrostWebViewClient import com.pitchedapps.frost.web.NestedWebView import com.pitchedapps.frost.web.shouldUseDesktopAgent +import kotlin.math.abs +import kotlin.math.max +import kotlin.math.min /** * Created by Allan Wang on 2017-05-29. @@ -89,7 +92,14 @@ class FrostWebView @JvmOverloads constructor( setDownloadListener { url, userAgent, contentDisposition, mimetype, contentLength -> context.ctxCoroutine.launchMain { val cookie = db.cookieDao().currentCookie() ?: return@launchMain - context.frostDownload(cookie, url, userAgent, contentDisposition, mimetype, contentLength) + context.frostDownload( + cookie, + url, + userAgent, + contentDisposition, + mimetype, + contentLength + ) } } return this @@ -163,14 +173,14 @@ class FrostWebView @JvmOverloads constructor( private fun smoothScrollTo(y: Int) { ValueAnimator.ofInt(scrollY, y).apply { - duration = Math.min(Math.abs(scrollY - y), 500).toLong() + duration = min(abs(scrollY - y), 500).toLong() interpolator = AnimHolder.fastOutSlowInInterpolator(context) addUpdateListener { scrollY = it.animatedValue as Int } start() } } - private fun smoothScrollBy(y: Int) = smoothScrollTo(Math.max(0, scrollY + y)) + private fun smoothScrollBy(y: Int) = smoothScrollTo(max(0, scrollY + y)) override var active: Boolean = true set(value) { |