Exemplo n.º 1
0
 public static int getColorFromIcon(Drawable icon, final Context context) {
   Palette palette = Palette.from(Utils.drawableToBitmap(icon)).generate();
   int resultColor = getBetterColor(palette.getVibrantColor(0));
   if (resultColor == 0) {
     resultColor = getBetterColor(palette.getMutedColor(0));
   }
   if (resultColor == 0) {
     resultColor =
         ContextCompat.getColor(
             context,
             ThemeUtils.darkTheme ? R.color.dark_theme_accent : R.color.light_theme_accent);
   }
   return resultColor;
 }
Exemplo n.º 2
0
 private void applyPalette() {
   mTitleHolder.setBackgroundColor(mPalette.getMutedColor(defaultColorForRipple));
 }