Java Code Examples for android.support.v7.graphics.Palette#getDarkMutedSwatch()
The following examples show how to use
android.support.v7.graphics.Palette#getDarkMutedSwatch() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaletteLoader.java From Mizuu with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(Palette result) { if (result != null) { // Add it to the Palette cache MizuuApplication.addToPaletteCache(getPaletteKey(), result); Palette.Swatch sw = result.getDarkVibrantSwatch(); if (sw == null) sw = result.getDarkMutedSwatch(); if (sw == null) sw = result.getVibrantSwatch(); if (sw != null) { // Set the found color mSwatchColor = sw.getRgb(); // Color the views colorViews(); mOnPaletteLoadedCallback.onPaletteLoaded(getSwatchColor()); } } }
Example 2
Source File: PaletteUtils.java From MediaNotification with Apache License 2.0 | 6 votes |
private static Palette.Swatch getBestPaletteSwatchFrom(Palette palette) { if (palette != null) { if (palette.getVibrantSwatch() != null) return palette.getVibrantSwatch(); else if (palette.getMutedSwatch() != null) return palette.getMutedSwatch(); else if (palette.getDarkVibrantSwatch() != null) return palette.getDarkVibrantSwatch(); else if (palette.getDarkMutedSwatch() != null) return palette.getDarkMutedSwatch(); else if (palette.getLightVibrantSwatch() != null) return palette.getLightVibrantSwatch(); else if (palette.getLightMutedSwatch() != null) return palette.getLightMutedSwatch(); else if (!palette.getSwatches().isEmpty()) return getBestPaletteSwatchFrom(palette.getSwatches()); } return null; }
Example 3
Source File: DetailActivity.java From RxAndroidBootstrap with Apache License 2.0 | 6 votes |
@Override public void onGenerated(Palette palette) { try { if (palette != null) { final Palette.Swatch darkVibrantSwatch = palette.getDarkVibrantSwatch(); final Palette.Swatch darkMutedSwatch = palette.getDarkMutedSwatch(); final Palette.Swatch lightVibrantSwatch = palette.getLightVibrantSwatch(); final Palette.Swatch lightMutedSwatch = palette.getLightMutedSwatch(); final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch(); final Palette.Swatch backgroundAndContentColors = (darkVibrantSwatch != null) ? darkVibrantSwatch : darkMutedSwatch; final Palette.Swatch titleAndFabColors = (darkVibrantSwatch != null) ? lightVibrantSwatch : lightMutedSwatch; toolbar.setBackgroundColor(backgroundAndContentColors.getRgb()); // bodyTextview.setBackgroundColor(backgroundAndContentColors.getRgb()); titleTextView.setTextColor(titleAndFabColors.getRgb()); } } catch (Exception e) { } }
Example 4
Source File: DetailActivity.java From MVPAndroidBootstrap with Apache License 2.0 | 6 votes |
@Override public void onGenerated(Palette palette) { try { if (palette != null) { final Palette.Swatch darkVibrantSwatch = palette.getDarkVibrantSwatch(); final Palette.Swatch darkMutedSwatch = palette.getDarkMutedSwatch(); final Palette.Swatch lightVibrantSwatch = palette.getLightVibrantSwatch(); final Palette.Swatch lightMutedSwatch = palette.getLightMutedSwatch(); final Palette.Swatch vibrantSwatch = palette.getVibrantSwatch(); final Palette.Swatch backgroundAndContentColors = (darkVibrantSwatch != null) ? darkVibrantSwatch : darkMutedSwatch; final Palette.Swatch titleAndFabColors = (darkVibrantSwatch != null) ? lightVibrantSwatch : lightMutedSwatch; mToolBarColor = backgroundAndContentColors.getRgb(); bodyTextview.setBackgroundColor(backgroundAndContentColors.getRgb()); titleTextView.setTextColor(titleAndFabColors.getRgb()); } } catch (Exception e) { cleanErrorHandler.logExpception(e); } }
Example 5
Source File: PhonographColorUtil.java From Orin with GNU General Public License v3.0 | 6 votes |
@ColorInt public static int getColor(@Nullable Palette palette, int fallback) { 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(); } else if (!palette.getSwatches().isEmpty()) { return Collections.max(palette.getSwatches(), SwatchComparator.getInstance()).getRgb(); } } return fallback; }
Example 6
Source File: RetroMusicColorUtil.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
@ColorInt public static int getColor(@Nullable Palette palette, int fallback) { 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(); } else if (!palette.getSwatches().isEmpty()) { return Collections.max(palette.getSwatches(), SwatchComparator.getInstance()).getRgb(); } } return fallback; }
Example 7
Source File: RetroMusicColorUtil.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
public static int[] getMultipleColor(Palette palette) { int[] colors = new int[2]; if (palette != null) { if (palette.getVibrantSwatch() != null) { colors[0] = palette.getVibrantSwatch().getRgb(); } else if (palette.getMutedSwatch() != null) { colors[1] = palette.getMutedSwatch().getRgb(); } else if (palette.getDarkVibrantSwatch() != null) { colors[0] = palette.getDarkVibrantSwatch().getRgb(); } else if (palette.getDarkMutedSwatch() != null) { colors[1] = palette.getDarkMutedSwatch().getRgb(); } else if (palette.getLightVibrantSwatch() != null) { colors[0] = palette.getLightVibrantSwatch().getRgb(); } else if (palette.getLightMutedSwatch() != null) { colors[1] = palette.getLightMutedSwatch().getRgb(); } else if (!palette.getSwatches().isEmpty()) { colors[0] = Collections.max(palette.getSwatches(), SwatchComparator.getInstance()).getRgb(); } } return colors; }
Example 8
Source File: ColorUtil.java From music_player with Open Software License 3.0 | 6 votes |
public static int getColor(Bitmap bitmap) { Palette palette = Palette.from(bitmap).generate(); 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(); } else { return Color.parseColor("#009688"); } }
Example 9
Source File: ColorUtil.java From APlayer with GNU General Public License v3.0 | 6 votes |
@ColorInt public static int getColor(@Nullable Palette palette, int fallback) { 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(); } else if (!palette.getSwatches().isEmpty()) { return Collections.max(palette.getSwatches(), SwatchComparator.getInstance()).getRgb(); } } return fallback; }
Example 10
Source File: ColorUtil.java From APlayer with GNU General Public License v3.0 | 6 votes |
public static Palette.Swatch getSwatch(Palette palette) { if (palette != null) { if (palette.getVibrantSwatch() != null) { return palette.getVibrantSwatch(); } else if (palette.getMutedSwatch() != null) { return palette.getMutedSwatch(); } else if (palette.getDarkVibrantSwatch() != null) { return palette.getDarkVibrantSwatch(); } else if (palette.getDarkMutedSwatch() != null) { return palette.getDarkMutedSwatch(); } else if (palette.getLightVibrantSwatch() != null) { return palette.getLightVibrantSwatch(); } else if (palette.getLightMutedSwatch() != null) { return palette.getLightMutedSwatch(); } else if (!palette.getSwatches().isEmpty()) { return Collections.max(palette.getSwatches(), SwatchComparator.getInstance()); } } return new Palette.Swatch(Color.GRAY, 100); }
Example 11
Source File: ViewUtils.java From materialup with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static RippleDrawable createRipple(@NonNull Palette palette, @FloatRange(from = 0f, to = 1f) float darkAlpha, @FloatRange(from = 0f, to = 1f) float lightAlpha, @ColorInt int fallbackColor, boolean bounded) { int rippleColor = fallbackColor; // try the named swatches in preference order if (palette.getVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getLightVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(), lightAlpha); } else if (palette.getDarkVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha); } else if (palette.getLightMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(), lightAlpha); } else if (palette.getDarkMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha); } return new RippleDrawable(ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null); }
Example 12
Source File: ImageUtil.java From Leisure with GNU Lesser General Public License v3.0 | 5 votes |
public static int getImageColor(Bitmap bitmap){ Palette palette = Palette.from(bitmap).generate(); if(palette == null || palette.getDarkMutedSwatch() == null){ return Color.LTGRAY; } return palette.getDarkMutedSwatch().getRgb(); }
Example 13
Source File: ShotFragment.java From droidddle with Apache License 2.0 | 5 votes |
private void updateShotPalette(Palette palette) { mDensity = getResources().getDisplayMetrics().density; int index = 0; Palette.Swatch swatch = palette.getDarkMutedSwatch(); if (swatch != null) { setPaletteColor(index, swatch); index++; } swatch = palette.getDarkVibrantSwatch(); if (swatch != null) { setPaletteColor(index, swatch); index++; } swatch = palette.getMutedSwatch(); if (swatch != null) { setPaletteColor(index, swatch); index++; } swatch = palette.getVibrantSwatch(); if (swatch != null) { setPaletteColor(index, swatch); index++; } swatch = palette.getLightMutedSwatch(); if (swatch != null) { setPaletteColor(index, swatch); index++; } swatch = palette.getLightVibrantSwatch(); if (swatch != null) { setPaletteColor(index, swatch); index++; } }
Example 14
Source File: ViewUtils.java From android-proguards with Apache License 2.0 | 5 votes |
public static RippleDrawable createRipple(@NonNull Palette palette, @FloatRange(from = 0f, to = 1f) float darkAlpha, @FloatRange(from = 0f, to = 1f) float lightAlpha, @ColorInt int fallbackColor, boolean bounded) { int rippleColor = fallbackColor; if (palette != null) { // try the named swatches in preference order if (palette.getVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getLightVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(), lightAlpha); } else if (palette.getDarkVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha); } else if (palette.getLightMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(), lightAlpha); } else if (palette.getDarkMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha); } } return new RippleDrawable(ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null); }
Example 15
Source File: ViewUtils.java From Protein with Apache License 2.0 | 5 votes |
public static RippleDrawable createRipple(@NonNull Palette palette, @FloatRange(from = 0f, to = 1f) float darkAlpha, @FloatRange(from = 0f, to = 1f) float lightAlpha, @ColorInt int fallbackColor, boolean bounded) { int rippleColor = fallbackColor; if (palette != null) { // try the named swatches in preference order if (palette.getVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getLightVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(), lightAlpha); } else if (palette.getDarkVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha); } else if (palette.getLightMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(), lightAlpha); } else if (palette.getDarkMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha); } } return new RippleDrawable(ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null); }
Example 16
Source File: ColorUtils.java From Musicoco with Apache License 2.0 | 5 votes |
/** * 获得图片中出现最多的颜色<br> * 0 暗的活力颜色<br> * 1 暗的活力颜色 对应适合的字体颜色<br> * 2 暗的柔和颜色<br> * 3 暗的柔和颜色 对应适合的字体颜色<br> */ public static void get4DarkColorWithTextFormBitmap(@NonNull Bitmap bitmap, int defaultColor, int defaultTextColor, int[] colors) { if (colors.length != 4) return; Palette palette; palette = new Palette.Builder(bitmap).generate(); Palette.Swatch swatch; int color = defaultColor; int textColor = defaultTextColor; if ((swatch = palette.getDarkVibrantSwatch()) != null) { color = swatch.getRgb(); textColor = swatch.getTitleTextColor(); } colors[0] = color; colors[1] = textColor; color = defaultColor; textColor = defaultTextColor; if ((swatch = palette.getDarkMutedSwatch()) != null) { color = swatch.getRgb(); textColor = swatch.getTitleTextColor(); } colors[2] = color; colors[3] = textColor; }
Example 17
Source File: ShotDetail.java From COCOFramework with Apache License 2.0 | 5 votes |
private void applyPalette(Palette palette) { if (palette == null || v == null) return; Palette.Swatch item = palette.getDarkMutedSwatch(); if (item == null) return; v.setBackgroundColor(item.getRgb()); mDescription.setTextColor(item.getBodyTextColor()); }
Example 18
Source File: MainActivity.java From TutosAndroidFrance with MIT License | 4 votes |
public void appliquerPalette(Palette palette) { { //je récupère le swatch Vibrant Palette.Swatch vibrant = palette.getVibrantSwatch(); if (vibrant != null) { //il se peut que la palette ne génère pas tous les swatch //j'utilise getRgb() en tant que couleurs de fond te ma textView textVibrant.setBackgroundColor(vibrant.getRgb()); //getBodyTextColor() est prévu pour être affiché dessus une vue en background getRgb() textVibrant.setTextColor(vibrant.getBodyTextColor()); } } { Palette.Swatch vibrantDark = palette.getDarkVibrantSwatch(); if (vibrantDark != null) { textVibrantDark.setBackgroundColor(vibrantDark.getRgb()); textVibrantDark.setTextColor(vibrantDark.getBodyTextColor()); } } { Palette.Swatch vibrantLight = palette.getLightVibrantSwatch(); if (vibrantLight != null) { textVibrantLight.setBackgroundColor(vibrantLight.getRgb()); textVibrantLight.setTextColor(vibrantLight.getBodyTextColor()); } } { Palette.Swatch muted = palette.getMutedSwatch(); if (muted != null) { textMuted.setBackgroundColor(muted.getRgb()); textMuted.setTextColor(muted.getBodyTextColor()); } } { Palette.Swatch mutedDark = palette.getDarkMutedSwatch(); if (mutedDark != null) { textMutedDark.setBackgroundColor(mutedDark.getRgb()); textMutedDark.setTextColor(mutedDark.getBodyTextColor()); } } { Palette.Swatch lightMuted = palette.getLightMutedSwatch(); if (lightMuted != null) { textMutedLight.setBackgroundColor(lightMuted.getRgb()); textMutedLight.setTextColor(lightMuted.getBodyTextColor()); } } }
Example 19
Source File: ColorUtils.java From Musicoco with Apache License 2.0 | 4 votes |
/** * 获得图片中出现最多的颜色 * 0 活力颜色<br> * 1 对应字体颜色<br> * 2 亮的活力颜色<br> * 3 对应字体颜色<br> * 4 暗的活力颜色<br> * 5 对应字体颜色<br> * 6 柔和颜色<br> * 7 对应字体颜色<br> * 8 亮的柔和颜色<br> * 9 对应字体颜色<br> * 10 暗的柔和颜色<br> * 11 对应字体颜色<br> */ public static void get12ColorFormBitmap(@NonNull Bitmap bitmap, int defaultColor, int defaultTextColor, int[] colors) { if (colors.length != 12) return; Palette palette; palette = new Palette.Builder(bitmap).generate(); Palette.Swatch swatch; int color; int tColor; if ((swatch = palette.getVibrantSwatch()) != null) { color = swatch.getRgb(); tColor = swatch.getTitleTextColor(); } else { color = defaultColor; tColor = defaultTextColor; } colors[0] = color; colors[1] = tColor; if ((swatch = palette.getLightVibrantSwatch()) != null) { color = swatch.getRgb(); tColor = swatch.getTitleTextColor(); } else { color = defaultColor; tColor = defaultTextColor; } colors[2] = color; colors[3] = tColor; if ((swatch = palette.getDarkVibrantSwatch()) != null) { color = swatch.getRgb(); tColor = swatch.getTitleTextColor(); } else { color = defaultColor; tColor = defaultTextColor; } colors[4] = color; colors[5] = tColor; if ((swatch = palette.getMutedSwatch()) != null) { color = swatch.getRgb(); tColor = swatch.getTitleTextColor(); } else { color = defaultColor; tColor = defaultTextColor; } colors[6] = color; colors[7] = tColor; if ((swatch = palette.getLightMutedSwatch()) != null) { color = swatch.getRgb(); tColor = swatch.getTitleTextColor(); } else { color = defaultColor; tColor = defaultTextColor; } colors[8] = color; colors[9] = tColor; if ((swatch = palette.getDarkMutedSwatch()) != null) { color = swatch.getRgb(); tColor = swatch.getTitleTextColor(); } else { color = defaultColor; tColor = defaultTextColor; } colors[10] = color; colors[11] = tColor; }
Example 20
Source File: ColorUtils.java From Musicoco with Apache License 2.0 | 4 votes |
/** * 获得图片中出现最多的颜色 * 0 活力颜色<br> * 1 亮的活力颜色<br> * 2 暗的活力颜色<br> * 3 柔和颜色<br> * 4 亮的柔和颜色<br> * 5 暗的柔和颜色<br> */ public static void get6ColorFormBitmap(@NonNull Bitmap bitmap, int defaultColor, int[] colors) { if (colors.length != 6) return; Palette palette; palette = new Palette.Builder(bitmap).generate(); Palette.Swatch swatch; int color; if ((swatch = palette.getVibrantSwatch()) != null) color = swatch.getRgb(); else color = defaultColor; colors[0] = color; if ((swatch = palette.getLightVibrantSwatch()) != null) color = swatch.getRgb(); else color = defaultColor; colors[1] = color; if ((swatch = palette.getDarkVibrantSwatch()) != null) color = swatch.getRgb(); else color = defaultColor; colors[2] = color; if ((swatch = palette.getMutedSwatch()) != null) color = swatch.getRgb(); else color = defaultColor; colors[3] = color; if ((swatch = palette.getLightMutedSwatch()) != null) color = swatch.getRgb(); else color = defaultColor; colors[4] = color; if ((swatch = palette.getDarkMutedSwatch()) != null) color = swatch.getRgb(); else color = defaultColor; colors[5] = color; }