diff options
| -rw-r--r-- | graphics/java/android/graphics/drawable/AnimationDrawable.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/drawable/AnimationDrawable.java b/graphics/java/android/graphics/drawable/AnimationDrawable.java index e1975c90312f..521c74b7ffc2 100644 --- a/graphics/java/android/graphics/drawable/AnimationDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimationDrawable.java @@ -105,10 +105,12 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An /** * Sets whether this AnimationDrawable is visible. * <p> - * When the drawable becomes invisible, it will pause its animation. A - * subsequent change to visible with <code>restart</code> set to true will - * restart the animation from the first frame. If <code>restart</code> is - * false, the animation will resume from the most recent frame. + * When the drawable becomes invisible, it will pause its animation. A subsequent change to + * visible with <code>restart</code> set to true will restart the animation from the + * first frame. If <code>restart</code> is false, the drawable will resume from the most recent + * frame. If the drawable has already reached the last frame, it will then loop back to the + * first frame, unless it's a one shot drawable (set through {@link #setOneShot(boolean)}), + * in which case, it will stay on the last frame. * * @param visible true if visible, false otherwise * @param restart when visible, true to force the animation to restart @@ -120,7 +122,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An final boolean changed = super.setVisible(visible, restart); if (visible) { if (restart || changed) { - boolean startFromZero = restart || !mRunning || + boolean startFromZero = restart || (!mRunning && !mAnimationState.mOneShot) || mCurFrame >= mAnimationState.getChildCount(); setFrame(startFromZero ? 0 : mCurFrame, true, mAnimating); } @@ -131,7 +133,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An } /** - * Starts the animation, looping if necessary. This method has no effect + * Starts the animation from the first frame, looping if necessary. This method has no effect * if the animation is running. * <p> * <strong>Note:</strong> Do not call this in the @@ -158,7 +160,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An } /** - * Stops the animation. This method has no effect if the animation is not + * Stops the animation at the current frame. This method has no effect if the animation is not * running. * * @see #isRunning() @@ -169,6 +171,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An mAnimating = false; if (isRunning()) { + mCurFrame = 0; unscheduleSelf(this); } } @@ -196,7 +199,6 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An @Override public void unscheduleSelf(Runnable what) { - mCurFrame = 0; mRunning = false; super.unscheduleSelf(what); } |