diff options
author | Allan Wang <me@allanwang.ca> | 2017-12-22 01:51:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-22 01:51:43 -0500 |
commit | bd96905dbfa6c1d4bde4257d61f381d4ee8e1fd0 (patch) | |
tree | e28732e64f6fc0bba715ae2b0a0383ea780d3a22 /app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt | |
parent | bd99aebf4388515273dfd720eb5c59b6e45da44f (diff) | |
download | frost-bd96905dbfa6c1d4bde4257d61f381d4ee8e1fd0.tar.gz frost-bd96905dbfa6c1d4bde4257d61f381d4ee8e1fd0.tar.bz2 frost-bd96905dbfa6c1d4bde4257d61f381d4ee8e1fd0.zip |
Update webview components (#571)
* Add volume binding
* Remove key override
* Add pause timers to webview
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 | 26 |
1 files changed, 16 insertions, 10 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 e6e1f0e2..0d04fcd9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -6,7 +6,7 @@ import android.content.Context import android.graphics.Color import android.util.AttributeSet import android.view.View -import android.view.animation.DecelerateInterpolator +import ca.allanwang.kau.utils.AnimHolder import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent @@ -106,23 +106,29 @@ class FrostWebView @JvmOverloads constructor( private fun scrollToTop() { flingScroll(0, 0) // stop fling - if (scrollY > 10000) { + if (scrollY > 10000) scrollTo(0, 0) - } else { - ValueAnimator.ofInt(scrollY, 0).apply { - duration = Math.min(scrollY, 500).toLong() - interpolator = DecelerateInterpolator() - addUpdateListener { scrollY = it.animatedValue as Int } - start() - } + else + smoothScrollTo(0) + } + + private fun smoothScrollTo(y: Int) { + ValueAnimator.ofInt(scrollY, y).apply { + duration = Math.min(Math.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)) + override var active: Boolean = true set(value) { if (field == value) return field = value - // todo + if (field) onResume() + else onPause() } override fun reloadTheme() { |