Merge "Clean up onAnimationEnd handling"
This commit is contained in:
committed by
Android (Google) Code Review
commit
a6671f9975
@@ -3,7 +3,9 @@ package com.android.systemui.qs;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Animatable2;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -44,6 +46,24 @@ public class PageIndicator extends ViewGroup {
|
||||
private int mPosition = -1;
|
||||
private boolean mAnimating;
|
||||
|
||||
private final Animatable2.AnimationCallback mAnimationCallback =
|
||||
new Animatable2.AnimationCallback() {
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Drawable drawable) {
|
||||
super.onAnimationEnd(drawable);
|
||||
if (DEBUG) Log.d(TAG, "onAnimationEnd - queued: " + mQueuedPositions.size());
|
||||
if (drawable instanceof AnimatedVectorDrawable) {
|
||||
((AnimatedVectorDrawable) drawable).unregisterAnimationCallback(
|
||||
mAnimationCallback);
|
||||
}
|
||||
mAnimating = false;
|
||||
if (mQueuedPositions.size() != 0) {
|
||||
setPosition(mQueuedPositions.remove(0));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public PageIndicator(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -197,10 +217,8 @@ public class PageIndicator extends ViewGroup {
|
||||
final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getContext().getDrawable(res);
|
||||
imageView.setImageDrawable(avd);
|
||||
avd.forceAnimationOnUI();
|
||||
avd.registerAnimationCallback(mAnimationCallback);
|
||||
avd.start();
|
||||
// TODO: Figure out how to user an AVD animation callback instead, which doesn't
|
||||
// seem to be working right now...
|
||||
postDelayed(mAnimationDone, ANIMATION_DURATION);
|
||||
}
|
||||
|
||||
private int getTransition(boolean fromB, boolean isMajorAState, boolean isMajor) {
|
||||
@@ -264,15 +282,4 @@ public class PageIndicator extends ViewGroup {
|
||||
getChildAt(i).layout(left, 0, mPageIndicatorWidth + left, mPageIndicatorHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private final Runnable mAnimationDone = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (DEBUG) Log.d(TAG, "onAnimationEnd - queued: " + mQueuedPositions.size());
|
||||
mAnimating = false;
|
||||
if (mQueuedPositions.size() != 0) {
|
||||
setPosition(mQueuedPositions.remove(0));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user