当前位置: 首页>>代码示例>>Java>>正文


Java Palette.getMutedColor方法代码示例

本文整理汇总了Java中android.support.v7.graphics.Palette.getMutedColor方法的典型用法代码示例。如果您正苦于以下问题:Java Palette.getMutedColor方法的具体用法?Java Palette.getMutedColor怎么用?Java Palette.getMutedColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.graphics.Palette的用法示例。


在下文中一共展示了Palette.getMutedColor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
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;
}
 
开发者ID:KishanV,项目名称:Android-Music-Player,代码行数:20,代码来源:thumbSlider.java

示例2: palette

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
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;
    }
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:35,代码来源:IconColorExtractor.java

示例3: initializeColorSeekBar

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
private void initializeColorSeekBar(Palette palette) {
    int defaultColor = 0x000000;
    int[] colors = {
            palette.getDominantColor(defaultColor),
            palette.getVibrantColor(defaultColor),
            palette.getMutedColor(defaultColor)};

    int px = ivPreview.getHeight() - (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics());
    sbColor = new ColorSeekBar(PreviewActivity.this);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, px, 0, 0);
    sbColor.setLayoutParams(params);
    sbColor.setColorSeeds(colors);
    sbColor.setBackground(ContextCompat.getDrawable(PreviewActivity.this, R.drawable.transparent));
    sbColor.setOnColorChangeListener(new ColorSeekBar.OnColorChangeListener() {
        @Override
        public void onColorChangeListener(int colorBarPosition, int alphaBarPosition, int color) {
            presenter.setColor(color);
        }
    });

    px = ivPreview.getHeight() - (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics());
    int h = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
    vSeekBarBacking = new View(PreviewActivity.this);
    params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, h);
    params.setMargins(0, px, 0, 0);
    vSeekBarBacking.setLayoutParams(params);
    GradientDrawable gradient = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, colors);
    gradient.setCornerRadius(0f);
    vSeekBarBacking.setBackground(gradient);

    rlRoot.addView(vSeekBarBacking);
    rlRoot.addView(sbColor);
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:38,代码来源:PreviewActivity.java

示例4: getTextColor

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
@ColorInt
public static int getTextColor(Context context, Palette palette, Palette.Swatch swatch) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    if (prefs.getBoolean(PreferenceUtils.PREF_HIGH_CONTRAST_TEXT, false)) {
        if (ColorUtils.isColorLight(swatch.getRgb()))
            return Color.BLACK;
        else return Color.WHITE;
    } else {
        int background = swatch.getRgb();
        if (prefs.getBoolean(PreferenceUtils.PREF_INVERSE_TEXT_COLORS, true)) {
            int inverse = -1;
            if (palette != null) {
                switch (prefs.getInt(PreferenceUtils.PREF_COLOR_METHOD, PreferenceUtils.COLOR_METHOD_DOMINANT)) {
                    case PreferenceUtils.COLOR_METHOD_DOMINANT:
                        inverse = ColorUtils.isColorSaturated(background) ? palette.getMutedColor(-1) : palette.getVibrantColor(-1);
                        break;
                    case PreferenceUtils.COLOR_METHOD_VIBRANT:
                        inverse = palette.getMutedColor(-1);
                        break;
                    case PreferenceUtils.COLOR_METHOD_MUTED:
                        inverse = palette.getVibrantColor(-1);
                        break;
                }

                if (inverse != -1)
                    return ColorUtils.getReadableText(inverse, background, 150);
            }

            /*inverse = ColorUtils.getInverseColor(background);
            if (ColorUtils.getDifference(background, inverse) > 120 && ColorUtils.isColorSaturated(background))
                return ColorUtils.getReadableText(inverse, background, 150);*/
        }
        return ColorUtils.getReadableText(background, background);
    }
}
 
开发者ID:TheAndroidMaster,项目名称:MediaNotification,代码行数:36,代码来源:PaletteUtils.java

示例5: loadBitmaps

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
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();
            }
        });
    }
}
 
开发者ID:KishanV,项目名称:Android-Music-Player,代码行数:30,代码来源:thumbSlider.java

示例6: loadBitmaps

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:KishanV,项目名称:Android-Music-Player,代码行数:34,代码来源:Screen.java

示例7: getLightThemeTarget

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
private Target getLightThemeTarget() {
	return new Target() {
		@Override
		public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
			streamerImage.setImageBitmap(bitmap);

			Palette palette = 		Palette.from(bitmap).generate();
			int defaultColor = 		Service.getColorAttribute(R.attr.colorPrimary, R.color.primary, getBaseContext());
			int defaultDarkColor = 	Service.getColorAttribute(R.attr.colorPrimaryDark, R.color.primaryDark, getBaseContext());

			int vibrant = 		palette.getVibrantColor(defaultColor);
			int vibrantDark = 	palette.getDarkVibrantColor(defaultColor);
			int vibrantLight = 	palette.getLightVibrantColor(defaultColor);

			int muted = 	 palette.getMutedColor(defaultColor);
			int mutedDark =  palette.getDarkMutedColor(defaultColor);
			int mutedLight = palette.getLightMutedColor(defaultColor);

			Palette.Swatch swatch = null;

			if (vibrant != defaultColor) {
				swatch = palette.getVibrantSwatch();
			} else if (vibrantDark != defaultColor) {
				swatch = palette.getDarkVibrantSwatch();
			} else if (vibrantLight != defaultColor){
				swatch = palette.getLightVibrantSwatch();
			} else if (muted != defaultColor) {
				swatch = palette.getMutedSwatch();
			} else if (mutedDark != defaultColor) {
				swatch = palette.getDarkMutedSwatch();
			} else {
				swatch = palette.getLightMutedSwatch();
			}

			if (swatch != null) {
				float[] swatchValues = swatch.getHsl();
				float[] newSwatch = {swatchValues[0], (float) 0.85, (float) 0.85};
				float[] newSwatchComposite = {(swatchValues[0] + 180) % 360, newSwatch[1], newSwatch[2]};
				float[] newSwatchDark = {newSwatch[0], newSwatch[1], (float) 0.6};

				int newColorDark = Color.HSVToColor(newSwatchDark);
				int newColor = Color.HSVToColor(newSwatch);
				int compositeNewColor = Color.HSVToColor(newSwatchComposite);

				int primaryColor = Service.getBackgroundColorFromView(toolbar, defaultColor);
				int primaryColorDark = Service.getBackgroundColorFromView(mTabs, defaultDarkColor);

				Service.animateBackgroundColorChange(toolbar, newColor, primaryColor, COLOR_FADE_DURATION);
				Service.animateBackgroundColorChange(additionalToolbar, newColor, primaryColor, COLOR_FADE_DURATION);
				Service.animateBackgroundColorChange(mTabs, newColorDark, primaryColorDark, COLOR_FADE_DURATION);
				mFab.setBackgroundTintList(ColorStateList.valueOf(compositeNewColor));
				mTabs.setSelectedTabIndicatorColor(compositeNewColor);

				if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
					Window window = getWindow();
					window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
					window.setStatusBarColor(newColorDark);
				}
			}
		}

		@Override
		public void onBitmapFailed(Drawable errorDrawable) {}

		@Override
		public void onPrepareLoad(Drawable placeHolderDrawable) {}
	};
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:69,代码来源:ChannelActivity.java


注:本文中的android.support.v7.graphics.Palette.getMutedColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。