Code example for Animator

Methods: addListener

0
        } 
    }; 
 
    public static void cancelOnDestroyActivity(Animator a) {
        sAnimators.add(a);
        a.addListener(sEndAnimListener);
    } 
 
    // Helper method. Assumes a draw is pending, and that if the animation's duration is 0 
    // it should be cancelled 
    public static void startAnimationAfterNextDraw(final Animator animator, final View view) {
        view.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
                private boolean mStarted = false;
                public void onDraw() { 
                    if (mStarted) return;
                    mStarted = true;
                    // Use this as a signal that the animation was cancelled 
                    if (animator.getDuration() == 0) {
                        return; 
                    } 
                    animator.start();