Example #1
0
 /**
  * {@inheritDoc}
  *
  * <p>Note that ending a <code>AnimatorSet</code> also ends all of the animations that it is
  * responsible for.
  */
 @Override
 public void end() {
   mTerminated = true;
   if (isStarted()) {
     if (mSortedNodes.size() != mNodes.size()) {
       // hasn't been started yet - sort the nodes now, then end them
       sortNodes();
       for (Node node : mSortedNodes) {
         if (mSetListener == null) {
           mSetListener = new AnimatorSetListener(this);
         }
         node.animation.addListener(mSetListener);
       }
     }
     if (mDelayAnim != null) {
       mDelayAnim.cancel();
     }
     if (mSortedNodes.size() > 0) {
       for (Node node : mSortedNodes) {
         node.animation.end();
       }
     }
     if (mListeners != null) {
       ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
       for (AnimatorListener listener : tmpListeners) {
         listener.onAnimationEnd(this);
       }
     }
     mStarted = false;
   }
 }
Example #2
0
 /**
  * {@inheritDoc}
  *
  * <p>Note that canceling a <code>AnimatorSet</code> also cancels all of the animations that it is
  * responsible for.
  */
 @SuppressWarnings("unchecked")
 @Override
 public void cancel() {
   mTerminated = true;
   if (isStarted()) {
     ArrayList<AnimatorListener> tmpListeners = null;
     if (mListeners != null) {
       tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
       for (AnimatorListener listener : tmpListeners) {
         listener.onAnimationCancel(this);
       }
     }
     if (mDelayAnim != null && mDelayAnim.isRunning()) {
       // If we're currently in the startDelay period, just cancel that animator and
       // send out the end event to all listeners
       mDelayAnim.cancel();
     } else if (mSortedNodes.size() > 0) {
       for (Node node : mSortedNodes) {
         node.animation.cancel();
       }
     }
     if (tmpListeners != null) {
       for (AnimatorListener listener : tmpListeners) {
         listener.onAnimationEnd(this);
       }
     }
     mStarted = false;
   }
 }