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

The following examples show how to use android.support.v7.graphics.Palette#getLightVibrantColor() . 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: thumbSlider.java    From Android-Music-Player with MIT License 6 votes vote down vote up
public int getColor(Bitmap bm){
    int color = thumbRing.Color0;
    if(bm != null){
        Palette palette = Palette.from(bm).generate();
        int newColor = palette.getMutedColor(color);
        if(newColor == color){
            newColor = palette.getVibrantColor(color);
        }
        if(newColor == color){
            newColor = palette.getLightVibrantColor(color);
        }
        if(newColor == color){
            newColor = palette.getDarkVibrantColor(color);
        }
        color = newColor;
    }
    //Log.i("My","Color Exacted : " + color);
    return  color;
}
 
Example 2
Source File: AlbumDetailActivity.java    From android-animations-transitions with MIT License 6 votes vote down vote up
private void colorizeFromImage(Bitmap image) {
        Palette palette = Palette.from(image).generate();

        // set panel colors
        int defaultPanelColor = 0xFF808080;
        int defaultFabColor = 0xFFEEEEEE;
        titlePanel.setBackgroundColor(palette.getDarkVibrantColor(defaultPanelColor));
        trackPanel.setBackgroundColor(palette.getLightMutedColor(defaultPanelColor));

        // set fab colors
        int[][] states = new int[][]{
                new int[]{android.R.attr.state_enabled},
                new int[]{android.R.attr.state_pressed}
        };

        int[] colors = new int[]{
                palette.getVibrantColor(defaultFabColor),
                palette.getLightVibrantColor(defaultFabColor)
        };
//        fab.setBackgroundTintList(new ColorStateList(states, colors));
    }
 
Example 3
Source File: AvatarManager.java    From timecat with Apache License 2.0 5 votes vote down vote up
public static int[] colorsFor(Resources res, String avatar) {

        int[] colors = new int[]{R.color.android_blue, R.color.android_blue_light};

        if (!cache.containsKey(avatar) && avatars.containsKey(avatar)) {
            Bitmap bm = BitmapFactory.decodeResource(res, avatars.get(avatar));
            if (bm != null) {
                Palette p = Palette.generate(bm);
                colors = new int[]{p.getVibrantColor(R.color.android_blue), p.getLightVibrantColor(R.color.android_blue_light)};
            }
            cache.put(avatar, colors);
        }
        return cache.get(avatar);
    }
 
Example 4
Source File: PaletteUtils.java    From AccountBook with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 通过 bitmap 对象获取其中的主色值。
 * @param bitmap
 * @return
 */
public static int getColorRgb(Bitmap bitmap) {
    Palette.Builder b = new Palette.Builder(bitmap);
    b.maximumColorCount(1);
    Palette palette = b.generate();
    if(palette.getSwatches().size() > 0){
        Palette.Swatch swatch = palette.getSwatches().get(0);
        if(swatch != null){
            return swatch.getRgb();
        }
    }else{
        return palette.getLightVibrantColor(UiUtils.getColor(R.color.colorAccent));
    }
    return -1;
}
 
Example 5
Source File: thumbSlider.java    From Android-Music-Player with MIT License 5 votes vote down vote up
void loadBitmaps(){
    if(Ui.ef.MusicPlayer != null){
        musicPlayer mp = Ui.ef.MusicPlayer;
        final Bitmap bm = audioHandler.getAlubumArtBitmapById(Ui.ef.getContentResolver(),mp.handler.AID);
        if(bm != null){
            Palette palette = Palette.from(bm).generate();
            int color = thumbRing.Color0;
            int newColor = palette.getMutedColor(color);
            if(newColor == color){
                newColor = palette.getVibrantColor(color);
            }
            if(newColor == color){
                newColor = palette.getLightVibrantColor(color);
            }
            threeThumb.ring.img.maskPaint.setColor(newColor);
        }else{
            threeThumb.ring.img.maskPaint.setColor(thumbRing.Color0);
        }

        Ui.ef.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                //threeThumb.setImg(bm);
                threeThumb.invalidate();
                threeThumb.ring.invalidate();
            }
        });
    }
}
 
Example 6
Source File: Screen.java    From Android-Music-Player with MIT License 5 votes vote down vote up
void loadBitmaps(){
    if(Ui.ef.MusicPlayer != null){
        musicPlayer mp = Ui.ef.MusicPlayer;
        final Bitmap bm = audioHandler.getAlubumArtBitmapById(Ui.ef.getContentResolver(),mp.handler.AID);
        if(bm != null){
            Palette palette = Palette.from(bm).generate();
            int color = thumbRing.Color0;
            int newColor = palette.getMutedColor(color);
            if(newColor == color){
                newColor = palette.getVibrantColor(color);
            }
            if(newColor == color){
                newColor = palette.getLightVibrantColor(color);
            }
            tRing.img.maskPaint.setColor(newColor);
        }else{
            tRing.img.maskPaint.setColor(thumbRing.Color0);
        }

        Ui.ef.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                tRing.invalidate();
                img.setImageDrawable(null);
                img.setImageBitmap(bm);
            }
        });

    }else{
        img.setImageDrawable(null);
        img.setImageBitmap(null);
    }
}
 
Example 7
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 8
Source File: DetailActivity.java    From MaterializeYourApp with Apache License 2.0 5 votes vote down vote up
private void updateBackground(FloatingActionButton fab, Palette palette) {
    int lightVibrantColor = palette.getLightVibrantColor(getResources().getColor(android.R.color.white));
    int vibrantColor = palette.getVibrantColor(getResources().getColor(R.color.accent));

    fab.setRippleColor(lightVibrantColor);
    fab.setBackgroundTintList(ColorStateList.valueOf(vibrantColor));
}
 
Example 9
Source File: TestFragment_Separate.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override public void onResourceReady(Palette palette,
		GlideAnimation<? super Palette> glideAnimation) {
	int color = palette.getLightVibrantColor(palette.getLightMutedColor(Color.WHITE));
	view.setBackgroundColor(color);
}
 
Example 10
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);
    }
}