1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.launcher3.anim; 18 19 import android.animation.Animator; 20 import android.animation.AnimatorListenerAdapter; 21 22 /** 23 * Extension of {@link AnimatorListenerAdapter} for listening for non-cancelled animations 24 */ 25 public abstract class AnimationSuccessListener extends AnimatorListenerAdapter { 26 27 protected boolean mCancelled = false; 28 29 @Override onAnimationCancel(Animator animation)30 public void onAnimationCancel(Animator animation) { 31 mCancelled = true; 32 } 33 34 @Override onAnimationEnd(Animator animation)35 public void onAnimationEnd(Animator animation) { 36 if (!mCancelled) { 37 onAnimationSuccess(animation); 38 } 39 } 40 onAnimationSuccess(Animator animator)41 public abstract void onAnimationSuccess(Animator animator); 42 } 43