aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-08-06 00:45:36 -0700
committerAllan Wang <me@allanwang.ca>2019-08-06 00:45:36 -0700
commit8ef5d04f28f63a34ca099a9b7e3b887f0ed122a6 (patch)
tree19c8ed9e4d4ebc131192adf0aa6edeef5368fcfb /app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
parente5b3dbf51bfd63b230bedcaa67893dda82dd66e2 (diff)
downloadfrost-8ef5d04f28f63a34ca099a9b7e3b887f0ed122a6.tar.gz
frost-8ef5d04f28f63a34ca099a9b7e3b887f0ed122a6.tar.bz2
frost-8ef5d04f28f63a34ca099a9b7e3b887f0ed122a6.zip
Use kotlin math
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.kt16
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) {