summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Romain Guy <romainguy@android.com> 2010-02-09 11:30:44 -0800
committer Romain Guy <romainguy@android.com> 2010-02-09 11:36:44 -0800
commit305a2eb8e5957a4f3db2734a8918faf1a39fb9a4 (patch)
tree4733d69aba3b7cf238dc751a79325dc8f22918f0
parentb37d8a484cb81b7cc58bc97c18507ec556b33468 (diff)
Properly notifies listener when an animation is cancelled.
Bug: #2428005.
-rw-r--r--api/current.xml11
-rw-r--r--core/java/android/view/View.java3
-rw-r--r--core/java/android/view/animation/Animation.java21
3 files changed, 35 insertions, 0 deletions
diff --git a/api/current.xml b/api/current.xml
index b155c4565241..3da6b72e1dda 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -181293,6 +181293,17 @@
<parameter name="t" type="android.view.animation.Transformation">
</parameter>
</method>
+<method name="cancel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="computeDurationHint"
return="long"
abstract="false"
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f5c465e6550e..889985ae9d71 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8281,6 +8281,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
* Cancels any animations for this view.
*/
public void clearAnimation() {
+ if (mCurrentAnimation != null) {
+ mCurrentAnimation.cancel();
+ }
mCurrentAnimation = null;
}
diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java
index 000e4ceded22..ad9825962634 100644
--- a/core/java/android/view/animation/Animation.java
+++ b/core/java/android/view/animation/Animation.java
@@ -256,6 +256,27 @@ public abstract class Animation implements Cloneable {
}
/**
+ * Cancel the animation. Cancelling an animation invokes the animation
+ * listener, if set, to notify the end of the animation.
+ *
+ * If you cancel an animation manually, you must call {@link #reset()}
+ * before starting the animation again.
+ *
+ * @see #reset()
+ * @see #start()
+ * @see #startNow()
+ */
+ public void cancel() {
+ if (mStarted && !mEnded) {
+ if (mListener != null) mListener.onAnimationEnd(this);
+ mEnded = true;
+ }
+ // Make sure we move the animation to the end
+ mStartTime = Long.MIN_VALUE;
+ mMore = mOneMoreTime = false;
+ }
+
+ /**
* Whether or not the animation has been initialized.
*
* @return Has this animation been initialized.