Skip to content

Instantly share code, notes, and snippets.

@yishai-glide
Created May 10, 2015 09:27
Show Gist options
  • Save yishai-glide/0cfd22eb486b6a74b27c to your computer and use it in GitHub Desktop.
Save yishai-glide/0cfd22eb486b6a74b27c to your computer and use it in GitHub Desktop.
foo(View source){
if(source == null) {
return;
}
View container = source.getParent();
getColorAnimation(container, true);
}
static ValueAnimator getColorAnimation(final View view, boolean shouldReverse)
{
Integer colorFrom = GlideApplication.applicationContext.getResources().getColor(R.color.transperent);
Integer colorTo = GlideApplication.applicationContext.getResources().getColor(R.color.black);
ValueAnimator colorAnimation = null;
if(shouldReverse)
{
colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorTo, colorFrom);
}
else
{
colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
}
colorAnimation.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
if(animator != null && animator.getAnimatedValue() != null)
{
view.setBackgroundColor((Integer)animator.getAnimatedValue());
}
}
});
colorAnimation.setDuration(SCALING_ANIM_DURATION);
colorAnimation.setInterpolator(new DecelerateInterpolator());
return colorAnimation;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment