Use disk cache

This commit is contained in:
Karim Abou Zeid 2016-01-02 23:57:14 +01:00
commit 533708e63d
18 changed files with 77 additions and 94 deletions

View file

@ -20,39 +20,14 @@ import com.kabouzeid.gramophone.R;
public class ColorUtil {
public static final int PALETTE_BITMAP_SIZE = 100;
@Deprecated
@ColorInt
public static int generateColor(Context context, Bitmap bitmap) {
return getColor(context, generatePalette(bitmap));
}
@Nullable
public static Palette generatePalette(Bitmap bitmap) {
if (bitmap == null) return null;
return Palette.from(bitmap)
.resizeBitmapSize(PALETTE_BITMAP_SIZE)
.generate();
}
@Deprecated
@ColorInt
public static int getColor(Context context, @Nullable Palette palette) {
if (palette != null) {
if (palette.getVibrantSwatch() != null) {
return palette.getVibrantSwatch().getRgb();
} else if (palette.getMutedSwatch() != null) {
return palette.getMutedSwatch().getRgb();
} else if (palette.getDarkVibrantSwatch() != null) {
return palette.getDarkVibrantSwatch().getRgb();
} else if (palette.getDarkMutedSwatch() != null) {
return palette.getDarkMutedSwatch().getRgb();
} else if (palette.getLightVibrantSwatch() != null) {
return palette.getLightVibrantSwatch().getRgb();
} else if (palette.getLightMutedSwatch() != null) {
return palette.getLightMutedSwatch().getRgb();
}
}
return ColorUtil.resolveColor(context, R.attr.default_bar_color);
}
@ColorInt
public static int getColor(@Nullable Palette palette, int fallback) {
if (palette != null) {