summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-06-30 12:39:18 -0700
committerRomain Guy <romainguy@android.com>2009-06-30 12:39:18 -0700
commitb5537c452271634b6ff3981b0624fa65384abd5b (patch)
tree66159c3caed7ad21c6afb61974b77278d32097aa /graphics
parent2f8d58b7ae2b9dc60eed83e5dddc8c28223e1ede (diff)
downloadframeworks_base-b5537c452271634b6ff3981b0624fa65384abd5b.zip
frameworks_base-b5537c452271634b6ff3981b0624fa65384abd5b.tar.gz
frameworks_base-b5537c452271634b6ff3981b0624fa65384abd5b.tar.bz2
Replace indeterminate progress animated asset with new ones
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/Animatable.java39
-rw-r--r--graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java27
-rw-r--r--graphics/java/android/graphics/drawable/AnimationDrawable.java2
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;