OSDN Git Service

Accessors for frame count and duration.
authorJeff Sharkey <jsharkey@android.com>
Tue, 30 Aug 2011 23:42:23 +0000 (16:42 -0700)
committerJeff Sharkey <jsharkey@android.com>
Tue, 30 Aug 2011 23:42:44 +0000 (16:42 -0700)
Bug: 5233703
Change-Id: If6a758540248dc9bff56b64add04984ebd7b6833

graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java

index 94a8488..7c4e147 100644 (file)
@@ -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) {