cancel animation On Activity Destroy - Android android.view.animation

Android examples for android.view.animation:Animation

Description

cancel animation On Activity Destroy

Demo Code

import java.util.HashSet;

import android.animation.Animator;

public class Main {

  static Animator.AnimatorListener sEndAnimListener = new Animator.AnimatorListener() {
    public void onAnimationStart(Animator animation) {
    }//from  w ww  .j  ava  2s  .  c  o m

    public void onAnimationRepeat(Animator animation) {
    }

    public void onAnimationEnd(Animator animation) {
      sAnimators.remove(animation);
    }

    public void onAnimationCancel(Animator animation) {
      sAnimators.remove(animation);
    }
  };
  static HashSet<Animator> sAnimators = new HashSet<Animator>();

  public static void cancelOnDestroyActivity(Animator a) {
    sAnimators.add(a);
    a.addListener(sEndAnimListener);
  }

}

Related Tutorials