forked from upstream-mirrors/quik
Optimize CIECLhEvaluator and ThemeManager.setActiveColor
This commit is contained in:
@@ -18,7 +18,13 @@ public class CIELChEvaluator implements TypeEvaluator<Integer> {
|
|||||||
private final ColorCIELCh mStartColor;
|
private final ColorCIELCh mStartColor;
|
||||||
private final ColorCIELCh mEndColor;
|
private final ColorCIELCh mEndColor;
|
||||||
|
|
||||||
|
private final int mStartInt;
|
||||||
|
private final int mEndInt;
|
||||||
|
|
||||||
public CIELChEvaluator(int startColor, int endColor) {
|
public CIELChEvaluator(int startColor, int endColor) {
|
||||||
|
mStartInt = startColor;
|
||||||
|
mEndInt = endColor;
|
||||||
|
|
||||||
mStartColor = convertRgbToCIELCH(startColor);
|
mStartColor = convertRgbToCIELCH(startColor);
|
||||||
mEndColor = convertRgbToCIELCH(endColor);
|
mEndColor = convertRgbToCIELCH(endColor);
|
||||||
}
|
}
|
||||||
@@ -29,6 +35,9 @@ public class CIELChEvaluator implements TypeEvaluator<Integer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer evaluate(float fraction, Integer ignored, Integer ignored2) {
|
public Integer evaluate(float fraction, Integer ignored, Integer ignored2) {
|
||||||
|
if (mStartInt == mEndInt) {
|
||||||
|
return mStartInt;
|
||||||
|
}
|
||||||
|
|
||||||
// CIELCH to CIELAB
|
// CIELCH to CIELAB
|
||||||
double L = mStartColor.L * (1 - fraction) + mEndColor.L * fraction;
|
double L = mStartColor.L * (1 - fraction) + mEndColor.L * fraction;
|
||||||
|
|||||||
@@ -621,8 +621,10 @@ public class ThemeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setActiveColor(int color) {
|
public static void setActiveColor(int color) {
|
||||||
mActiveColor = color;
|
if (mActiveColor != color) {
|
||||||
LiveViewManager.refreshViews(QKPreference.THEME);
|
mActiveColor = color;
|
||||||
|
LiveViewManager.refreshViews(QKPreference.THEME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isColorDarkEnough(int color) {
|
private static boolean isColorDarkEnough(int color) {
|
||||||
|
|||||||
Reference in New Issue
Block a user