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

The following examples show how to use android.support.v7.graphics.Palette#getDarkMutedColor() . 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: RecyclerAdapterFav.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {

    byte[] posterImage = itemsModels.get(position).getPosterImage();
    holder.image.setImageBitmap(BitmapUtility.getImage(posterImage));
    holder.title.setText(itemsModels.get(position).getName());
    holder.genre.setText(itemsModels.get(position).getGenre());

    //int vibrant = BitmapUtility.getPaletteColor(holder.image);
    //holder.linearLayout.setBackgroundColor(vibrant);

    BitmapDrawable drawable = (BitmapDrawable) holder.image.getDrawable();
    Bitmap bitmap = drawable.getBitmap();

    Palette palette = Palette.generate(bitmap);
    int defaultColor = 0xFF333333;
    int color = palette.getDarkMutedColor(defaultColor);
    holder.linearLayout.setBackgroundColor(color);

}
 
Example 2
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 3
Source File: ContentActivity.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
private void applyPalette(Palette palette) {
    int colorMuted = palette.getDarkMutedColor(getResources().getColor(android.R.color.black));
    int colorLightVibrant = palette.getLightVibrantColor(getResources().getColor(android.R.color.primary_text_dark));
    int colorVibrant = palette.getVibrantColor(getResources().getColor(android.R.color.primary_text_dark));

    getWindow().setBackgroundDrawable(new ColorDrawable(colorMuted));
    textTitle.setTextColor(colorLightVibrant);
    textContent.setTextColor(colorVibrant);
}
 
Example 4
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);
    }
}