Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d32b317 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Accessors for frame count and duration.

Bug: 5233703
Change-Id: If6a758540248dc9bff56b64add04984ebd7b6833
parent be1a0493
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -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();
    }
@@ -229,8 +233,8 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
        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;
@@ -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) {