Fix not animating icons
When the icon is not animating, we need to move it to the end state. To do that, we call stop. We also need to call start, as the animator set may not have been initialized. Fixes: 257278678 Test: atest QSIconViewImplTest Test: manual Change-Id: I356342a185e63efc2e3b8d25b8c57e20e1ad62bc
This commit is contained in:
@@ -140,16 +140,21 @@ public class QSIconViewImpl extends QSIconView {
|
||||
iv.setTag(R.id.qs_icon_tag, icon);
|
||||
iv.setTag(R.id.qs_slash_tag, state.slash);
|
||||
iv.setPadding(0, padding, 0, padding);
|
||||
if (shouldAnimate && d instanceof Animatable2) {
|
||||
if (d instanceof Animatable2) {
|
||||
Animatable2 a = (Animatable2) d;
|
||||
a.start();
|
||||
if (state.isTransient) {
|
||||
a.registerAnimationCallback(new AnimationCallback() {
|
||||
@Override
|
||||
public void onAnimationEnd(Drawable drawable) {
|
||||
a.start();
|
||||
}
|
||||
});
|
||||
if (shouldAnimate) {
|
||||
if (state.isTransient) {
|
||||
a.registerAnimationCallback(new AnimationCallback() {
|
||||
@Override
|
||||
public void onAnimationEnd(Drawable drawable) {
|
||||
a.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Sends animator to end of animation. Needs to be called after calling start.
|
||||
a.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ import com.android.systemui.plugins.qs.QSTile.State;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@UiThreadTest
|
||||
@@ -138,7 +140,7 @@ public class QSIconViewImplTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIconNotAnimatedWhenAllowAnimationsFalse() {
|
||||
public void testIconStartedAndStoppedWhenAllowAnimationsFalse() {
|
||||
ImageView iv = new ImageView(mContext);
|
||||
AnimatedVectorDrawable d = mock(AnimatedVectorDrawable.class);
|
||||
State s = new State();
|
||||
@@ -148,7 +150,9 @@ public class QSIconViewImplTest extends SysuiTestCase {
|
||||
|
||||
mIconView.updateIcon(iv, s, false);
|
||||
|
||||
verify(d, never()).start();
|
||||
InOrder inOrder = Mockito.inOrder(d);
|
||||
inOrder.verify(d).start();
|
||||
inOrder.verify(d).stop();
|
||||
}
|
||||
|
||||
private static Drawable.ConstantState fakeConstantState(Drawable otherDrawable) {
|
||||
|
||||
Reference in New Issue
Block a user