Various fixes and improvements
This commit is contained in:
parent
5f0bfdb14b
commit
6b68c17ae2
26 changed files with 142 additions and 121 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package com.kabouzeid.gramophone.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
|
|
@ -50,16 +49,6 @@ public class ColorUtil {
|
|||
return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static ColorStateList getEmptyColorStateList(@ColorInt int color) {
|
||||
return new ColorStateList(
|
||||
new int[][]{
|
||||
new int[]{}
|
||||
},
|
||||
new int[]{color}
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean useDarkTextColorOnBackground(@ColorInt int backgroundColor) {
|
||||
return (Color.red(backgroundColor) * 0.299 + Color.green(backgroundColor) * 0.587 + Color.blue(backgroundColor) * 0.114) > (255 / 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,22 +67,6 @@ public class ViewUtil {
|
|||
view.setBackgroundColor(a + rgb);
|
||||
}
|
||||
|
||||
public static void addOnGlobalLayoutListener(@NonNull final View view, @NonNull final Runnable runnable) {
|
||||
ViewTreeObserver vto = view.getViewTreeObserver();
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||
//noinspection deprecation
|
||||
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
} else {
|
||||
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
runnable.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called in {@link android.app.Activity#onPrepareOptionsMenu(Menu)} and {@link android.app.Activity#onOptionsItemSelected(MenuItem)}
|
||||
*
|
||||
|
|
@ -136,7 +120,7 @@ public class ViewUtil {
|
|||
|
||||
CheckBox check = (CheckBox) checkboxField.get(iv);
|
||||
if (check != null) {
|
||||
MDTintHelper.setTint(check, ThemeSingleton.get().positiveColor);
|
||||
MDTintHelper.setTint(check, ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
check.setBackground(null);
|
||||
}
|
||||
|
|
@ -144,7 +128,7 @@ public class ViewUtil {
|
|||
|
||||
RadioButton radioButton = (RadioButton) radioButtonField.get(iv);
|
||||
if (radioButton != null) {
|
||||
MDTintHelper.setTint(radioButton, ThemeSingleton.get().positiveColor);
|
||||
MDTintHelper.setTint(radioButton, ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
radioButton.setBackground(null);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue