diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-01 16:01:40 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-07-01 16:01:40 -0700 |
commit | 0901c82336c79ca3e3d67b1df8a5cb7ee45ec13e (patch) | |
tree | 483d47532562125fe502d91724b8055c651dc1ad /graphics/java | |
parent | f888bc4dfe75c990874a8ca793a6217d38ef2757 (diff) | |
parent | 91c91b74df12e40c31a50ecb807ac60bed2ccb58 (diff) | |
download | frameworks_base-0901c82336c79ca3e3d67b1df8a5cb7ee45ec13e.zip frameworks_base-0901c82336c79ca3e3d67b1df8a5cb7ee45ec13e.tar.gz frameworks_base-0901c82336c79ca3e3d67b1df8a5cb7ee45ec13e.tar.bz2 |
am 91c91b74: Merge change 5817 into donut
Merge commit '91c91b74df12e40c31a50ecb807ac60bed2ccb58'
* commit '91c91b74df12e40c31a50ecb807ac60bed2ccb58':
Replace indeterminate progress animated asset with new ones
Diffstat (limited to 'graphics/java')
3 files changed, 62 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/drawable/Animatable.java b/graphics/java/android/graphics/drawable/Animatable.java new file mode 100644 index 0000000..9dc62c3 --- /dev/null +++ b/graphics/java/android/graphics/drawable/Animatable.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.graphics.drawable; + +/** + * Interface that drawables suporting animations should implement. + */ +public interface Animatable { + /** + * Starts the drawable's animation. + */ + void start(); + + /** + * Stops the drawable's animation. + */ + void stop(); + + /** + * Indicates whether the animation is running. + * + * @return True if the animation is running, false otherwise. + */ + boolean isRunning(); +} diff --git a/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java b/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java index 08d295d..ac96f20 100644 --- a/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java @@ -35,11 +35,14 @@ import com.android.internal.R; /** * @hide */ -public class AnimatedRotateDrawable extends Drawable implements Drawable.Callback, Runnable { +public class AnimatedRotateDrawable extends Drawable implements Drawable.Callback, Runnable, + Animatable { + private AnimatedRotateState mState; private boolean mMutated; private float mCurrentDegrees; private float mIncrement; + private boolean mRunning; public AnimatedRotateDrawable() { this(null); @@ -80,10 +83,24 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac drawable.draw(canvas); canvas.restoreToCount(saveCount); - - nextFrame(); } - + + public void start() { + if (!mRunning) { + mRunning = true; + nextFrame(); + } + } + + public void stop() { + mRunning = false; + unscheduleSelf(this); + } + + public boolean isRunning() { + return mRunning; + } + private void nextFrame() { unscheduleSelf(this); scheduleSelf(this, SystemClock.uptimeMillis() + mState.mFrameDuration); @@ -96,8 +113,8 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac if (mCurrentDegrees > (360.0f - mIncrement)) { mCurrentDegrees = 0.0f; } - nextFrame(); invalidateSelf(); + nextFrame(); } @Override diff --git a/graphics/java/android/graphics/drawable/AnimationDrawable.java b/graphics/java/android/graphics/drawable/AnimationDrawable.java index bab1703..68718c9 100644 --- a/graphics/java/android/graphics/drawable/AnimationDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimationDrawable.java @@ -71,7 +71,7 @@ import android.util.AttributeSet; * @attr ref android.R.styleable#AnimationDrawableItem_duration * @attr ref android.R.styleable#AnimationDrawableItem_drawable */ -public class AnimationDrawable extends DrawableContainer implements Runnable { +public class AnimationDrawable extends DrawableContainer implements Runnable, Animatable { private final AnimationState mAnimationState; private int mCurFrame = -1; private boolean mMutated; |