replace some infrequently used methods from theme library

This commit is contained in:
dkanada 2021-06-13 00:36:58 +09:00
commit 5ae5d3017a
9 changed files with 76 additions and 53 deletions

View file

@ -111,6 +111,7 @@ public class ImageUtil {
public static Bitmap resize(InputStream stream, int scaledWidth, int scaledHeight) {
final Bitmap bitmap = BitmapFactory.decodeStream(stream);
return Bitmap.createScaledBitmap(bitmap, scaledWidth, scaledHeight, true);
}
}

View file

@ -1,5 +1,6 @@
package com.dkanada.gramophone.util;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import androidx.annotation.ColorInt;
@ -19,6 +20,20 @@ public class ThemeUtil {
return Palette.from(bitmap).generate();
}
public static ColorStateList getColorStateList(int normal, int active) {
int[][] states = new int[][]{
new int[]{-android.R.attr.state_checked},
new int[]{android.R.attr.state_checked}
};
int[] colors = new int[]{
normal,
active
};
return new ColorStateList(states, colors);
}
@ColorInt
public static int getColor(@Nullable Palette palette, int fallback) {
if (palette != null) {