Accessors for frame count and duration.
Bug: 5233703 Change-Id: If6a758540248dc9bff56b64add04984ebd7b6833
This commit is contained in:
@@ -55,7 +55,7 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
|
||||
|
||||
private void init() {
|
||||
final AnimatedRotateState state = mState;
|
||||
mIncrement = 360.0f / (float) state.mFramesCount;
|
||||
mIncrement = 360.0f / state.mFramesCount;
|
||||
final Drawable drawable = state.mDrawable;
|
||||
if (drawable != null) {
|
||||
drawable.setFilterBitmap(true);
|
||||
@@ -65,6 +65,7 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
int saveCount = canvas.save();
|
||||
|
||||
@@ -146,14 +147,17 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
|
||||
| mState.mDrawable.getChangingConfigurations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
mState.mDrawable.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
mState.mDrawable.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return mState.mDrawable.getOpacity();
|
||||
}
|
||||
@@ -228,10 +232,10 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
|
||||
tv = a.peekValue(R.styleable.AnimatedRotateDrawable_pivotY);
|
||||
final boolean pivotYRel = tv.type == TypedValue.TYPE_FRACTION;
|
||||
final float pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
|
||||
|
||||
final int framesCount = a.getInt(R.styleable.AnimatedRotateDrawable_framesCount, 12);
|
||||
final int frameDuration = a.getInt(R.styleable.AnimatedRotateDrawable_frameDuration, 150);
|
||||
|
||||
|
||||
setFramesCount(a.getInt(R.styleable.AnimatedRotateDrawable_framesCount, 12));
|
||||
setFramesDuration(a.getInt(R.styleable.AnimatedRotateDrawable_frameDuration, 150));
|
||||
|
||||
final int res = a.getResourceId(R.styleable.AnimatedRotateDrawable_drawable, 0);
|
||||
Drawable drawable = null;
|
||||
if (res > 0) {
|
||||
@@ -265,8 +269,6 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
|
||||
rotateState.mPivotX = pivotX;
|
||||
rotateState.mPivotYRel = pivotYRel;
|
||||
rotateState.mPivotY = pivotY;
|
||||
rotateState.mFramesCount = framesCount;
|
||||
rotateState.mFrameDuration = frameDuration;
|
||||
|
||||
init();
|
||||
|
||||
@@ -275,6 +277,15 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
|
||||
}
|
||||
}
|
||||
|
||||
public void setFramesCount(int framesCount) {
|
||||
mState.mFramesCount = framesCount;
|
||||
mIncrement = 360.0f / mState.mFramesCount;
|
||||
}
|
||||
|
||||
public void setFramesDuration(int framesDuration) {
|
||||
mState.mFrameDuration = framesDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable mutate() {
|
||||
if (!mMutated && super.mutate() == this) {
|
||||
|
||||
Reference in New Issue
Block a user