Skip to content

Instantly share code, notes, and snippets.

@orip
Last active December 25, 2015 02:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orip/6901005 to your computer and use it in GitHub Desktop.
Save orip/6901005 to your computer and use it in GitHub Desktop.
Helper to simulate withEndAction in NineOldAndroids http://nineoldandroids.com/
package com.example;
import com.nineoldandroids.animation.Animator;
/*
* animate(view).alpha(0).setListener(AnimationUtils.withEndAction(new Runnable() {
* public void run() {
* view.setVisibility(View.GONE);
* view.setAlpha(1); // restore alpha
* }
* }));
*/
public class AnimationUtils {
public static Animator.AnimatorListener withEndAction(final Runnable runnable) {
return new Animator.AnimatorListener() {
public void onAnimationStart(Animator animation) {
}
public void onAnimationEnd(Animator animation) {
runnable.run();
}
public void onAnimationCancel(Animator animation) {
}
public void onAnimationRepeat(Animator animation) {
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment