Merge "Don't animate grayscale if animations are off" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ab7af71c64
@@ -144,22 +144,26 @@ public class QSIconViewImpl extends QSIconView {
|
||||
}
|
||||
|
||||
public static void animateGrayScale(int fromColor, int toColor, ImageView iv) {
|
||||
final float fromAlpha = Color.alpha(fromColor);
|
||||
final float toAlpha = Color.alpha(toColor);
|
||||
final float fromChannel = Color.red(fromColor);
|
||||
final float toChannel = Color.red(toColor);
|
||||
if (ValueAnimator.areAnimatorsEnabled()) {
|
||||
final float fromAlpha = Color.alpha(fromColor);
|
||||
final float toAlpha = Color.alpha(toColor);
|
||||
final float fromChannel = Color.red(fromColor);
|
||||
final float toChannel = Color.red(toColor);
|
||||
|
||||
ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
|
||||
anim.setDuration(QS_ANIM_LENGTH);
|
||||
ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
|
||||
anim.setDuration(QS_ANIM_LENGTH);
|
||||
anim.addUpdateListener(animation -> {
|
||||
float fraction = animation.getAnimatedFraction();
|
||||
int alpha = (int) (fromAlpha + (toAlpha - fromAlpha) * fraction);
|
||||
int channel = (int) (fromChannel + (toChannel - fromChannel) * fraction);
|
||||
|
||||
anim.addUpdateListener(animation -> {
|
||||
float fraction = animation.getAnimatedFraction();
|
||||
int alpha = (int) (fromAlpha + (toAlpha - fromAlpha) * fraction);
|
||||
int channel = (int) (fromChannel + (toChannel - fromChannel) * fraction);
|
||||
setTint(iv, Color.argb(alpha, channel, channel, channel));
|
||||
});
|
||||
|
||||
setTint(iv, Color.argb(alpha, channel, channel, channel));
|
||||
});
|
||||
anim.start();
|
||||
anim.start();
|
||||
} else {
|
||||
setTint(iv, toColor);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTint(ImageView iv, int color) {
|
||||
|
||||
Reference in New Issue
Block a user