mirror of
https://github.com/Michatec/Radio.git
synced 2026-03-31 23:46:28 +02:00
Add rotation animation to playback button for mobile devices
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.ClipData
|
|||||||
import android.content.ClipboardManager
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.drawable.AnimatedVectorDrawable
|
import android.graphics.drawable.AnimatedVectorDrawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -328,8 +329,15 @@ data class LayoutHolder(var rootView: View) {
|
|||||||
|
|
||||||
/* Initiates the rotation animation of the play button */
|
/* Initiates the rotation animation of the play button */
|
||||||
fun animatePlaybackButtonStateTransition(context: Context, isPlaying: Boolean) {
|
fun animatePlaybackButtonStateTransition(context: Context, isPlaying: Boolean) {
|
||||||
// Toggle play button immediately for snappier feel
|
if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
|
||||||
togglePlayButton(isPlaying)
|
// TV: Toggle play button immediately for snappier feel
|
||||||
|
togglePlayButton(isPlaying)
|
||||||
|
} else {
|
||||||
|
// Handy/Tablet: Rotate the play button
|
||||||
|
val rotateAnimation = AnimationUtils.loadAnimation(context, if (isPlaying) R.anim.rotate_clockwise_slow else R.anim.rotate_counterclockwise_fast)
|
||||||
|
rotateAnimation.setAnimationListener(createAnimationListener(isPlaying))
|
||||||
|
playButtonView.startAnimation(rotateAnimation)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -371,7 +379,7 @@ data class LayoutHolder(var rootView: View) {
|
|||||||
return object : Animation.AnimationListener {
|
return object : Animation.AnimationListener {
|
||||||
override fun onAnimationStart(animation: Animation) {}
|
override fun onAnimationStart(animation: Animation) {}
|
||||||
override fun onAnimationEnd(animation: Animation) {
|
override fun onAnimationEnd(animation: Animation) {
|
||||||
// set up button symbol and playback indicator afterwards
|
// set up button symbol and playback indicator afterward
|
||||||
togglePlayButton(isPlaying)
|
togglePlayButton(isPlaying)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user