Respect disabled animations
This commit is contained in:
parent
c25e523df6
commit
452fe3a8e2
|
@ -58,7 +58,7 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
||||||
|
|
||||||
initTap = false
|
initTap = false
|
||||||
|
|
||||||
secondsView.stop()
|
secondsView.stopAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDoubleTapProgressDown(portion: DisplayPortion) {
|
override fun onDoubleTapProgressDown(portion: DisplayPortion) {
|
||||||
|
@ -86,8 +86,6 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
||||||
wasForwarding = shouldForward
|
wasForwarding = shouldForward
|
||||||
|
|
||||||
if (!initTap) {
|
if (!initTap) {
|
||||||
// Start animation
|
|
||||||
secondsView.start()
|
|
||||||
initTap = true
|
initTap = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +102,8 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
||||||
|
|
||||||
if (initTap) performListener?.onDoubleTabEnd()
|
if (initTap) performListener?.onDoubleTabEnd()
|
||||||
initTap = false
|
initTap = false
|
||||||
|
|
||||||
|
secondsView.stopAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeConstraints(forward: Boolean) {
|
private fun changeConstraints(forward: Boolean) {
|
||||||
|
@ -115,7 +115,7 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
||||||
secondsView.id, if (forward) END else START,
|
secondsView.id, if (forward) END else START,
|
||||||
PARENT_ID, if (forward) END else START
|
PARENT_ID, if (forward) END else START
|
||||||
)
|
)
|
||||||
secondsView.start()
|
secondsView.startAnimation()
|
||||||
applyTo(rootConstraintLayout)
|
applyTo(rootConstraintLayout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.databinding.PlayerFastSeekSecondsViewBinding
|
import org.schabi.newpipe.databinding.PlayerFastSeekSecondsViewBinding
|
||||||
|
import org.schabi.newpipe.util.DeviceUtils
|
||||||
|
|
||||||
class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) {
|
class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) {
|
||||||
|
|
||||||
|
@ -33,6 +34,9 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Done as a field so that we don't have to compute on each tab if animations are enabled
|
||||||
|
private val animationsEnabled = DeviceUtils.hasAnimationsAnimatorDurationEnabled(context)
|
||||||
|
|
||||||
val binding = PlayerFastSeekSecondsViewBinding.inflate(LayoutInflater.from(context), this)
|
val binding = PlayerFastSeekSecondsViewBinding.inflate(LayoutInflater.from(context), this)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -44,12 +48,18 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
|
||||||
binding.triangleContainer.rotation = if (isForward) 0f else 180f
|
binding.triangleContainer.rotation = if (isForward) 0f else 180f
|
||||||
}
|
}
|
||||||
|
|
||||||
fun start() {
|
fun startAnimation() {
|
||||||
stop()
|
stopAnimation()
|
||||||
|
|
||||||
|
if (animationsEnabled) {
|
||||||
firstAnimator.start()
|
firstAnimator.start()
|
||||||
|
} else {
|
||||||
|
// If no animations are enable show the arrow(s) without animation
|
||||||
|
showWithoutAnimation()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun stopAnimation() {
|
||||||
firstAnimator.cancel()
|
firstAnimator.cancel()
|
||||||
secondAnimator.cancel()
|
secondAnimator.cancel()
|
||||||
thirdAnimator.cancel()
|
thirdAnimator.cancel()
|
||||||
|
@ -65,6 +75,12 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
|
||||||
binding.icon3.alpha = 0f
|
binding.icon3.alpha = 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showWithoutAnimation() {
|
||||||
|
binding.icon1.alpha = 1f
|
||||||
|
binding.icon2.alpha = 1f
|
||||||
|
binding.icon3.alpha = 1f
|
||||||
|
}
|
||||||
|
|
||||||
private val firstAnimator: ValueAnimator = CustomValueAnimator(
|
private val firstAnimator: ValueAnimator = CustomValueAnimator(
|
||||||
{
|
{
|
||||||
binding.icon1.alpha = 0f
|
binding.icon1.alpha = 0f
|
||||||
|
|
Loading…
Reference in New Issue