@@ -8,6 +8,7 @@ import android.view.LayoutInflater
88import android.widget.LinearLayout
99import org.schabi.newpipe.R
1010import org.schabi.newpipe.databinding.PlayerFastSeekSecondsViewBinding
11+ import org.schabi.newpipe.util.DeviceUtils
1112
1213class SecondsView (context : Context , attrs : AttributeSet ? ) : LinearLayout(context, attrs) {
1314
@@ -33,6 +34,9 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
3334 field = value
3435 }
3536
37+ // Done as a field so that we don't have to compute on each tab if animations are enabled
38+ private val animationsEnabled = DeviceUtils .hasAnimationsAnimatorDurationEnabled(context)
39+
3640 val binding = PlayerFastSeekSecondsViewBinding .inflate(LayoutInflater .from(context), this )
3741
3842 init {
@@ -44,12 +48,18 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
4448 binding.triangleContainer.rotation = if (isForward) 0f else 180f
4549 }
4650
47- fun start () {
48- stop()
49- firstAnimator.start()
51+ fun startAnimation () {
52+ stopAnimation()
53+
54+ if (animationsEnabled) {
55+ firstAnimator.start()
56+ } else {
57+ // If no animations are enable show the arrow(s) without animation
58+ showWithoutAnimation()
59+ }
5060 }
5161
52- fun stop () {
62+ fun stopAnimation () {
5363 firstAnimator.cancel()
5464 secondAnimator.cancel()
5565 thirdAnimator.cancel()
@@ -65,6 +75,12 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
6575 binding.icon3.alpha = 0f
6676 }
6777
78+ private fun showWithoutAnimation () {
79+ binding.icon1.alpha = 1f
80+ binding.icon2.alpha = 1f
81+ binding.icon3.alpha = 1f
82+ }
83+
6884 private val firstAnimator: ValueAnimator = CustomValueAnimator (
6985 {
7086 binding.icon1.alpha = 0f
0 commit comments