diff options
| author | 2010-08-25 16:32:37 -0700 | |
|---|---|---|
| committer | 2010-08-25 17:32:27 -0700 | |
| commit | 673e42fafd4088970ec95e1f13c61dc83132c74e (patch) | |
| tree | 65bb234c96e59c1482fcd5569393da5c31d1876c | |
| parent | dc059804666c35abf51d09481f2fe5516339fcc6 (diff) | |
Fix for end events from Sequencer objects
Change-Id: I8947d8b016b880f9f54f2bf6ab22b4e188cdb29a
| -rw-r--r-- | api/current.xml | 22 | ||||
| -rw-r--r-- | core/java/android/animation/Animatable.java | 7 | ||||
| -rwxr-xr-x | core/java/android/animation/Animator.java | 16 | ||||
| -rw-r--r-- | core/java/android/animation/Sequencer.java | 31 | ||||
| -rw-r--r-- | core/java/android/text/TextLine.java | 2 |
5 files changed, 58 insertions, 20 deletions
diff --git a/api/current.xml b/api/current.xml index 619b2573d523..ebb8b3e19f6f 100644 --- a/api/current.xml +++ b/api/current.xml @@ -19870,6 +19870,17 @@ visibility="public" > </method> +<method name="isRunning" + return="boolean" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="removeAllListeners" return="void" abstract="false" @@ -20968,6 +20979,17 @@ visibility="public" > </method> +<method name="isRunning" + return="boolean" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="play" return="android.animation.Sequencer.Builder" abstract="false" diff --git a/core/java/android/animation/Animatable.java b/core/java/android/animation/Animatable.java index a49ca8fca7f6..d6cf7c08a691 100644 --- a/core/java/android/animation/Animatable.java +++ b/core/java/android/animation/Animatable.java @@ -56,6 +56,13 @@ public abstract class Animatable implements Cloneable { public void end() { } + + /** + * Returns whether this Animatable is currently running (having been started and not yet ended). + * @return Whether the Animatable is running. + */ + public abstract boolean isRunning(); + /** * Adds a listener to the set of listeners that are sent events through the life of an * animation, such as start, repeat, and end. diff --git a/core/java/android/animation/Animator.java b/core/java/android/animation/Animator.java index 18017bae0dc3..71b6d99c9172 100755 --- a/core/java/android/animation/Animator.java +++ b/core/java/android/animation/Animator.java @@ -699,15 +699,21 @@ public class Animator<T> extends Animatable { @Override public void end() { + if (!sAnimations.contains(this) && + (Thread.currentThread() == Looper.getMainLooper().getThread())) { + // Special case if the animation has not yet started. Set the end value. + long endTime = mDuration; + if (mRepeatCount > 0) { + endTime += mRepeatCount * mDuration; + } + setCurrentPlayTime(endTime); + } // Just set the ENDED flag - this causes the animation to end the next time a frame // is processed. mPlayingState = ENDED; } - /** - * Returns whether this Animator is currently running (having been started and not yet ended). - * @return Wehther the Animator is running. - */ + @Override public boolean isRunning() { return mPlayingState == RUNNING; } @@ -737,6 +743,7 @@ public class Animator<T> extends Animatable { */ private void endAnimation() { sAnimations.remove(this); + mPlayingState = STOPPED; if (mListeners != null) { ArrayList<AnimatableListener> tmpListeners = (ArrayList<AnimatableListener>) mListeners.clone(); @@ -744,7 +751,6 @@ public class Animator<T> extends Animatable { listener.onAnimationEnd(this); } } - mPlayingState = STOPPED; } /** diff --git a/core/java/android/animation/Sequencer.java b/core/java/android/animation/Sequencer.java index 77494290f9e4..a9e4e3bbf7dd 100644 --- a/core/java/android/animation/Sequencer.java +++ b/core/java/android/animation/Sequencer.java @@ -241,6 +241,21 @@ public final class Sequencer extends Animatable { } /** + * Returns true if any of the child animations of this Sequencer have been started and have not + * yet ended. + * @return Whether this Sequencer has been started and has not yet ended. + */ + @Override + public boolean isRunning() { + for (Node node : mNodes) { + if (node.animation.isRunning()) { + return true; + } + } + return false; + } + + /** * {@inheritDoc} * * <p>Starting this <code>Sequencer</code> will, in turn, start the animations for which @@ -467,14 +482,10 @@ public final class Sequencer extends Animatable { public void onAnimationEnd(Animatable animation) { animation.removeListener(this); mPlayingSet.remove(animation); - Node animNode = mSequencer.mNodeMap.get(animation); - animNode.done = true; ArrayList<Node> sortedNodes = mSequencer.mSortedNodes; - int numNodes = sortedNodes.size(); - int nodeIndex = sortedNodes.indexOf(animNode); boolean allDone = true; - for (int i = nodeIndex + 1; i < numNodes; ++i) { - if (!sortedNodes.get(i).done) { + for (Node node : sortedNodes) { + if (node.animation.isRunning()) { allDone = false; break; } @@ -558,7 +569,6 @@ public final class Sequencer extends Animatable { } } } - node.done = false; // also reset done flag } } } @@ -626,13 +636,6 @@ public final class Sequencer extends Animatable { public ArrayList<Node> nodeDependents = null; /** - * Flag indicating whether the animation in this node is finished. This flag - * is used by Sequencer to check, as each animation ends, whether all child animations - * are done and it's time to send out an end event for the entire Sequencer. - */ - public boolean done = false; - - /** * Constructs the Node with the animation that it encapsulates. A Node has no * dependencies by default; dependencies are added via the addDependency() * method. diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index 0e3522e7a0d6..2f7482c2f15d 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -75,7 +75,7 @@ class TextLine { } } tl = new TextLine(); - Log.e("TLINE", "new: " + tl); + Log.v("TLINE", "new: " + tl); return tl; } |