Prevent flat controls from animating on every show
This commit is contained in:
parent
8a20f127a3
commit
7b039741c3
1 changed files with 25 additions and 18 deletions
|
|
@ -67,6 +67,8 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
||||||
|
|
||||||
private AnimatorSet musicControllerAnimationSet;
|
private AnimatorSet musicControllerAnimationSet;
|
||||||
|
|
||||||
|
private boolean hidden = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
@ -253,6 +255,7 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
|
if (hidden) {
|
||||||
if (musicControllerAnimationSet == null) {
|
if (musicControllerAnimationSet == null) {
|
||||||
TimeInterpolator interpolator = new FastOutSlowInInterpolator();
|
TimeInterpolator interpolator = new FastOutSlowInInterpolator();
|
||||||
final int duration = 300;
|
final int duration = 300;
|
||||||
|
|
@ -265,7 +268,6 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
||||||
addAnimation(animators, shuffleButton, interpolator, duration, 200);
|
addAnimation(animators, shuffleButton, interpolator, duration, 200);
|
||||||
addAnimation(animators, repeatButton, interpolator, duration, 200);
|
addAnimation(animators, repeatButton, interpolator, duration, 200);
|
||||||
|
|
||||||
|
|
||||||
musicControllerAnimationSet = new AnimatorSet();
|
musicControllerAnimationSet = new AnimatorSet();
|
||||||
musicControllerAnimationSet.playTogether(animators);
|
musicControllerAnimationSet.playTogether(animators);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -274,6 +276,9 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
||||||
musicControllerAnimationSet.start();
|
musicControllerAnimationSet.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void hide() {
|
||||||
if (musicControllerAnimationSet != null) {
|
if (musicControllerAnimationSet != null) {
|
||||||
musicControllerAnimationSet.cancel();
|
musicControllerAnimationSet.cancel();
|
||||||
|
|
@ -283,6 +288,8 @@ public class FlatPlayerPlaybackControlsFragment extends AbsMusicServiceFragment
|
||||||
prepareForAnimation(prevButton);
|
prepareForAnimation(prevButton);
|
||||||
prepareForAnimation(shuffleButton);
|
prepareForAnimation(shuffleButton);
|
||||||
prepareForAnimation(repeatButton);
|
prepareForAnimation(repeatButton);
|
||||||
|
|
||||||
|
hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addAnimation(Collection<Animator> animators, View view, TimeInterpolator interpolator, int duration, int delay) {
|
private static void addAnimation(Collection<Animator> animators, View view, TimeInterpolator interpolator, int duration, int delay) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue