Skip to content

Commit

Permalink
fixed changing color on old devices bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zagum committed Jan 12, 2017
1 parent e4b4016 commit 77eb674
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class SwitchIconView extends AppCompatImageView {
private int dashThickness;
private int dashLengthXProjection;
private int dashLengthYProjection;
private final PorterDuffColorFilter colorFilter;
private PorterDuffColorFilter colorFilter;
private final ArgbEvaluator colorEvaluator = new ArgbEvaluator();

@FloatRange(from = 0f, to = 1f)
Expand Down Expand Up @@ -279,9 +279,10 @@ private void updateImageAlphaWithoutInvalidate(int alpha) {
}

private void updateImageColor(int color) {
ReflectionUtils.setValue(colorFilter, "mColor", color);
colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
ReflectionUtils.setValue(this, "mColorFilter", colorFilter);
Class<?> noParams[] = {};
ReflectionUtils.callMethod(colorFilter, "update", noParams);
ReflectionUtils.callMethod(this, "applyColorMod", noParams);
}

private void postInvalidateOnAnimationCompat() {
Expand Down

0 comments on commit 77eb674

Please sign in to comment.