if (listener != null) {
view.animate().setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
listener.onAnimationCancel(view);
}
@Override
public void onAnimationEnd(Animator animation) {
listener.onAnimationEnd(view);
}
@Override
public void onAnimationStart(Animator animation) {
listener.onAnimationStart(view);
}
});
} else {
view.animate().setListener(null);
}