Esempio n. 1
0
 @Override
 @SuppressWarnings("unchecked")
 public void onAnimationEnd(Animator animation) {
   animation.removeListener(this);
   mPlayingSet.remove(animation);
   Node animNode = mAnimatorSet.mNodeMap.get(animation);
   animNode.done = true;
   if (!mTerminated) {
     // Listeners are already notified of the AnimatorSet ending in cancel() or
     // end(); the logic below only kicks in when animations end normally
     ArrayList<Node> sortedNodes = mAnimatorSet.mSortedNodes;
     boolean allDone = true;
     int numSortedNodes = sortedNodes.size();
     for (int i = 0; i < numSortedNodes; ++i) {
       if (!sortedNodes.get(i).done) {
         allDone = false;
         break;
       }
     }
     if (allDone) {
       // If this was the last child animation to end, then notify listeners that this
       // AnimatorSet has ended
       if (mListeners != null) {
         ArrayList<AnimatorListener> tmpListeners =
             (ArrayList<AnimatorListener>) mListeners.clone();
         int numListeners = tmpListeners.size();
         for (int i = 0; i < numListeners; ++i) {
           tmpListeners.get(i).onAnimationEnd(mAnimatorSet);
         }
       }
       mAnimatorSet.mStarted = false;
     }
   }
 }
Esempio n. 2
0
 /**
  * Check whether the event received is one that the node was waiting for. If so, mark it as
  * complete and see whether it's time to start the animation.
  *
  * @param dependencyAnimation the animation that sent the event.
  */
 private void startIfReady(Animator dependencyAnimation) {
   if (mAnimatorSet.mTerminated) {
     // if the parent AnimatorSet was canceled, then don't start any dependent anims
     return;
   }
   Dependency dependencyToRemove = null;
   int numDependencies = mNode.tmpDependencies.size();
   for (int i = 0; i < numDependencies; ++i) {
     Dependency dependency = mNode.tmpDependencies.get(i);
     if (dependency.rule == mRule && dependency.node.animation == dependencyAnimation) {
       // rule fired - remove the dependency and listener and check to
       // see whether it's time to start the animation
       dependencyToRemove = dependency;
       dependencyAnimation.removeListener(this);
       break;
     }
   }
   mNode.tmpDependencies.remove(dependencyToRemove);
   if (mNode.tmpDependencies.size() == 0) {
     // all dependencies satisfied: start the animation
     mNode.animation.start();
     mAnimatorSet.mPlayingSet.add(mNode.animation);
   }
 }