Code example for Animator

Methods: addListener

    public static void cancelOnDestroyActivity(Animator a) {
    // 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) {
Stop searching for code, let great code find you!  Add Codota to your java IDE