Skip to content

Instantly share code, notes, and snippets.

@mahdi-malv
Last active November 8, 2018 11:15
Show Gist options
  • Save mahdi-malv/0ba6c3503cd30e50d6a659db03287f51 to your computer and use it in GitHub Desktop.
Save mahdi-malv/0ba6c3503cd30e50d6a659db03287f51 to your computer and use it in GitHub Desktop.
Fade in animation for fast splash usage
public void singleFadeInView(View v, long duration, final Consumer<Animation> onAnimEnd) {
AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f);
anim.setDuration(duration);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
onAnimEnd.accept(animation);
}
@Override
public void onAnimationRepeat(Animation animation) {}
});
v.startAnimation(anim);
}
fun singleFadeInView(v: View, duration: Long, onAnimEnd: () -> Unit) {
val anim = AlphaAnimation(0.0f, 1.0f)
anim.duration = duration
anim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationRepeat(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
onAnimEnd()
}
override fun onAnimationStart(animation: Animation?) {
}
})
v.startAnimation(anim)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment