Fix problems with early ending of Sequencer

Change-Id: Ib7548059ee3d3d713b78f86a2d290be4397c167d
diff --git a/core/java/android/animation/Animator.java b/core/java/android/animation/Animator.java
index 71b6d99..717fc0a 100755
--- a/core/java/android/animation/Animator.java
+++ b/core/java/android/animation/Animator.java
@@ -669,6 +669,7 @@
             setCurrentPlayTime(getCurrentPlayTime());
         }
         mPlayingState = STOPPED;
+        mStartedDelay = false;
         sPendingAnimations.add(this);
         if (sAnimationHandler == null) {
             sAnimationHandler = new AnimationHandler();
diff --git a/core/java/android/animation/Sequencer.java b/core/java/android/animation/Sequencer.java
index a9e4e3b..63ec940 100644
--- a/core/java/android/animation/Sequencer.java
+++ b/core/java/android/animation/Sequencer.java
@@ -233,6 +233,10 @@
     @Override
     public void end() {
         mCanceled = true;
+        if (mSortedNodes.size() != mNodes.size()) {
+            // hasn't been started yet - sort the nodes now, then end them
+            sortNodes();
+        }
         if (mSortedNodes.size() > 0) {
             for (Node node : mSortedNodes) {
                 node.animation.end();