Optimize CIECLhEvaluator and ThemeManager.setActiveColor

This commit is contained in:
Moez Bhatti
2016-07-07 17:46:58 -04:00
parent b91473e50b
commit 7e701af4c7
2 changed files with 13 additions and 2 deletions
@@ -18,7 +18,13 @@ public class CIELChEvaluator implements TypeEvaluator<Integer> {
private final ColorCIELCh mStartColor;
private final ColorCIELCh mEndColor;
private final int mStartInt;
private final int mEndInt;
public CIELChEvaluator(int startColor, int endColor) {
mStartInt = startColor;
mEndInt = endColor;
mStartColor = convertRgbToCIELCH(startColor);
mEndColor = convertRgbToCIELCH(endColor);
}
@@ -29,6 +35,9 @@ public class CIELChEvaluator implements TypeEvaluator<Integer> {
@Override
public Integer evaluate(float fraction, Integer ignored, Integer ignored2) {
if (mStartInt == mEndInt) {
return mStartInt;
}
// CIELCH to CIELAB
double L = mStartColor.L * (1 - fraction) + mEndColor.L * fraction;
@@ -621,8 +621,10 @@ public class ThemeManager {
}
public static void setActiveColor(int color) {
mActiveColor = color;
LiveViewManager.refreshViews(QKPreference.THEME);
if (mActiveColor != color) {
mActiveColor = color;
LiveViewManager.refreshViews(QKPreference.THEME);
}
}
private static boolean isColorDarkEnough(int color) {