Java Code Examples for android.support.v7.graphics.Palette#getLightMutedColor()

The following examples show how to use android.support.v7.graphics.Palette#getLightMutedColor() . 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: IconColorExtractor.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
private static ArrayList<Integer> palette(Palette p, int defaultColor) {

        ArrayList<Integer> extractedPalette = new ArrayList<>();

        //get all palettes
        Integer lightVibrant, vibrant, darkVibrant, lightMuted, muted, darkMuted;

        lightVibrant = p.getVibrantColor(defaultColor);
        vibrant = p.getVibrantColor(defaultColor);
        darkVibrant = p.getDarkVibrantColor(defaultColor);
        lightMuted = p.getLightMutedColor(defaultColor);
        muted = p.getMutedColor(defaultColor);
        darkMuted = p.getDarkMutedColor(defaultColor);

        extractedPalette.add(lightVibrant);
        extractedPalette.add(vibrant);
        extractedPalette.add(darkVibrant);
        extractedPalette.add(lightMuted);
        extractedPalette.add(muted);
        extractedPalette.add(darkMuted);

        //add also default color, because if the next method fails we have a color anyway
        extractedPalette.add(defaultColor);

        //pass these palettes to a hashset to avoid duplicates
        HashSet<Integer> hashSet = new HashSet<>();
        hashSet.addAll(extractedPalette);

        //add back these values to the palettes array list
        extractedPalette.clear();
        extractedPalette.addAll(hashSet);

        return extractedPalette;
    }
 
Example 2
Source File: MuzeiArtworkImageLoader.java    From FORMWatchFace with Apache License 2.0 5 votes vote down vote up
private Pair<Integer, Integer> extractColors(Bitmap bitmap) {
    Palette palette = Palette.generate(bitmap, 16);
    int midColor = palette.getVibrantColor(
            palette.getDarkVibrantColor(
                    palette.getMutedColor(
                            palette.getDarkMutedColor(Color.GRAY))));
    int lightColor = palette.getLightMutedColor(
            palette.getLightVibrantColor(
                    palette.getMutedColor(Color.BLACK)));
    if (lightColor == Color.BLACK) {
        lightColor = lighten(midColor, 0.2f);
    }
    return new Pair<>(lightColor, midColor);
}
 
Example 3
Source File: PaletteFragment.java    From AndroidMaterialDesign with Apache License 2.0 4 votes vote down vote up
@Override
public void initViews(View view) {
    showTitleBack(view, "Palette");
    tvVibrant = (TextView) view.findViewById(R.id.tv_vibrant);
    tvVibrantLight = (TextView) view.findViewById(R.id.tv_vibrant_light);
    tvVibrantDark = (TextView) view.findViewById(R.id.tv_vibrant_dark);
    tvMuted = (TextView) view.findViewById(R.id.tv_muted);
    tvMutedLight = (TextView) view.findViewById(R.id.tv_muted_light);
    tvMutedDark = (TextView) view.findViewById(R.id.tv_muted_dark);


    tvMutedSwatch = (TextView) view.findViewById(R.id.tv_muted_swatch);
    tvLightMutedSwatch = (TextView) view.findViewById(R.id.tv_light_muted_swatch);
    tvDarkMutedSwatch = (TextView) view.findViewById(R.id.tv_dark_muted_swatch);

    tvVibrantSwatch = (TextView) view.findViewById(R.id.tv_vibrant_swatch);
    tvLightVibrantSwatch = (TextView) view.findViewById(R.id.tv_light_vibrant_swatch);
    tvDarkVibrantSwatch = (TextView) view.findViewById(R.id.tv_dark_vibrant_swatch);

    Palette.PaletteAsyncListener paletteListener = new Palette.PaletteAsyncListener() {
        public void onGenerated(Palette palette) {

            int defaultColor = 0x000000;
            int vibrant = palette.getVibrantColor(defaultColor);
            int vibrantLight = palette.getLightVibrantColor(defaultColor);
            int vibrantDark = palette.getDarkVibrantColor(defaultColor);
            int muted = palette.getMutedColor(defaultColor);
            int mutedLight = palette.getLightMutedColor(defaultColor);
            int mutedDark = palette.getDarkMutedColor(defaultColor);

            tvVibrant.setBackgroundColor(vibrant);
            tvVibrantLight.setBackgroundColor(vibrantLight);
            tvVibrantDark.setBackgroundColor(vibrantDark);
            tvMuted.setBackgroundColor(muted);
            tvMutedLight.setBackgroundColor(mutedLight);
            tvMutedDark.setBackgroundColor(mutedDark);

            setSwatchColor(palette.getMutedSwatch(), tvMutedSwatch);
            setSwatchColor(palette.getLightMutedSwatch(), tvLightMutedSwatch);
            setSwatchColor(palette.getDarkMutedSwatch(), tvDarkMutedSwatch);

            setSwatchColor(palette.getVibrantSwatch(), tvVibrantSwatch);
            setSwatchColor(palette.getLightVibrantSwatch(), tvLightVibrantSwatch);
            setSwatchColor(palette.getDarkVibrantSwatch(), tvDarkVibrantSwatch);

        }
    };

    Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.titanic);
    if (myBitmap != null && !myBitmap.isRecycled()) {
        Palette.from(myBitmap).generate(paletteListener);
    }
}