Created
May 10, 2015 09:27
-
-
Save yishai-glide/0cfd22eb486b6a74b27c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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