本文整理汇总了Java中android.support.v7.graphics.Palette.getMutedSwatch方法的典型用法代码示例。如果您正苦于以下问题:Java Palette.getMutedSwatch方法的具体用法?Java Palette.getMutedSwatch怎么用?Java Palette.getMutedSwatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.graphics.Palette
的用法示例。
在下文中一共展示了Palette.getMutedSwatch方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColor
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static int getColor (Palette p){
Palette.Swatch s1 = p.getVibrantSwatch();
Palette.Swatch s3 = p.getDarkVibrantSwatch();
Palette.Swatch s2 = p.getMutedSwatch();
Palette.Swatch s6 = p.getDarkMutedSwatch();
Palette.Swatch s4 = p.getLightVibrantSwatch();
Palette.Swatch s5 = p.getLightMutedSwatch();
Palette.Swatch s7 = p.getDominantSwatch();
if (s1 != null) {
return s1.getRgb();
} else if (s2 != null) {
return s2.getRgb();
} else if (s3 != null) {
return s3.getRgb();
} else if (s4 != null) {
return s4.getRgb();
} else if (s5 != null) {
return s5.getRgb();
} else if (s6 != null) {
return s6.getRgb();
} else if (s7 != null) {
return s7.getRgb();
} else {
return Color.parseColor("#009688");
}
}
示例2: getColor
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
@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;
}
示例3: getBestPaletteSwatchFrom
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
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;
}
示例4: createRipple
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
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);
}
示例5: getSwatch
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static Palette.Swatch getSwatch(Context context, Palette palette) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (palette == null)
return new Palette.Swatch(prefs.getInt(PreferenceUtils.PREF_CUSTOM_COLOR, Color.WHITE), 1);
Palette.Swatch swatch = null;
switch (prefs.getInt(PreferenceUtils.PREF_COLOR_METHOD, PreferenceUtils.COLOR_METHOD_DOMINANT)) {
case PreferenceUtils.COLOR_METHOD_DOMINANT:
swatch = palette.getDominantSwatch();
break;
case PreferenceUtils.COLOR_METHOD_PRIMARY:
swatch = getBestPaletteSwatchFrom(palette);
break;
case PreferenceUtils.COLOR_METHOD_VIBRANT:
swatch = palette.getVibrantSwatch();
break;
case PreferenceUtils.COLOR_METHOD_MUTED:
swatch = palette.getMutedSwatch();
break;
}
if (swatch == null)
swatch = new Palette.Swatch(prefs.getInt(PreferenceUtils.PREF_CUSTOM_COLOR, Color.WHITE), 1);
return swatch;
}
示例6: definePaletteAsyncListener
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
* Defines a palette listener.
* @param title title
* @param textRating text rating
* @param rating rating
* @param starRating star rating
* @return palette
*/
public static PaletteAsyncListener definePaletteAsyncListener(final Context context,
final TextView title,
final TextView textRating,
final LinearLayout rating,
final ImageView starRating) {
return new PaletteAsyncListener() {
@SuppressLint("NewApi")
@Override
public void onGenerated(Palette palette) {
if (LOG) {
Log.v(TAG, "textSwatch.PaletteAsyncListener");
}
Palette.Swatch textSwatch = palette.getMutedSwatch();
Palette.Swatch bgSwatch = palette.getDarkVibrantSwatch();
if (textSwatch != null && bgSwatch != null) {
title.setTextColor(textSwatch.getTitleTextColor());
title.setBackgroundColor(textSwatch.getRgb());
textRating.setTextColor(bgSwatch.getTitleTextColor());
rating.setBackgroundColor(bgSwatch.getRgb());
starRating.setBackgroundColor(bgSwatch.getTitleTextColor());
} else if (bgSwatch != null) {
title.setBackgroundColor(bgSwatch.getRgb());
title.setTextColor(bgSwatch.getBodyTextColor());
rating.setBackgroundColor(bgSwatch.getBodyTextColor());
textRating.setTextColor(bgSwatch.getRgb());
starRating.setBackgroundColor(bgSwatch.getRgb());
} else if (textSwatch != null) {
title.setBackgroundColor(textSwatch.getRgb());
title.setTextColor(textSwatch.getBodyTextColor());
rating.setBackgroundColor(textSwatch.getBodyTextColor());
textRating.setTextColor(textSwatch.getRgb());
starRating.setBackgroundColor(textSwatch.getRgb());
} else {
title.setTextColor(
context.getResources().getColor(R.color.textcolorPrimary, null));
title.setBackgroundColor(
context.getResources().getColor(R.color.colorPrimary, null));
textRating.setTextColor(
context.getResources().getColor(R.color.textcolorSec, null));
rating.setBackgroundColor(
context.getResources().getColor(R.color.colorBackground, null));
}
}
};
}
示例7: getColor
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
@ColorInt
public static int getColor(@Nullable Palette palette, int defaultColor)
{
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 defaultColor;
}
示例8: createRipple
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
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 =
ColorUtil.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha);
} else if (palette.getLightVibrantSwatch() != null) {
rippleColor = ColorUtil.modifyAlpha(palette.getLightVibrantSwatch().getRgb(),
lightAlpha);
} else if (palette.getDarkVibrantSwatch() != null) {
rippleColor = ColorUtil.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(),
darkAlpha);
} else if (palette.getMutedSwatch() != null) {
rippleColor = ColorUtil.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha);
} else if (palette.getLightMutedSwatch() != null) {
rippleColor = ColorUtil.modifyAlpha(palette.getLightMutedSwatch().getRgb(),
lightAlpha);
} else if (palette.getDarkMutedSwatch() != null) {
rippleColor =
ColorUtil.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha);
}
}
return new RippleDrawable(ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null);
}
示例9: getAvailableColor
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
* Return Array with palette color
*
* @param context
* @param palette
* @return
*/
public static int[] getAvailableColor(Context context, Palette palette) {
int[] temp = new int[3]; //array with size 3
if (palette.getVibrantSwatch() != null) {
temp[0] = palette.getVibrantSwatch().getRgb();
temp[1] = palette.getVibrantSwatch().getTitleTextColor();
temp[2] = palette.getVibrantSwatch().getBodyTextColor();
} else if (palette.getMutedSwatch() != null) {
temp[0] = palette.getMutedSwatch().getRgb();
temp[1] = palette.getMutedSwatch().getTitleTextColor();
temp[2] = palette.getMutedSwatch().getBodyTextColor();
} else if (palette.getDarkVibrantSwatch() != null) {
temp[0] = palette.getDarkVibrantSwatch().getRgb();
temp[1] = palette.getDarkVibrantSwatch().getTitleTextColor();
temp[2] = palette.getDarkVibrantSwatch().getBodyTextColor();
} else if (palette.getDarkMutedSwatch() != null) {
temp[0] = palette.getDarkMutedSwatch().getRgb();
temp[1] = palette.getDarkMutedSwatch().getTitleTextColor();
temp[2] = palette.getDarkMutedSwatch().getBodyTextColor();
} else if (palette.getDominantSwatch() != null) {
temp[0] = palette.getDominantSwatch().getRgb();
temp[1] = palette.getDominantSwatch().getTitleTextColor();
temp[2] = palette.getDominantSwatch().getBodyTextColor();
} else {
String atkey = Helper.getATEKey(context);
int accent = Config.accentColor(context, atkey);
temp[0] = accent;
temp[1] = 0xffe5e5e5;
temp[2] = accent;
}
return temp;
}
示例10: getAvailableColor
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public static int[] getAvailableColor(Context context, Palette palette) {
int[] temp = new int[3]; //array with size 3
if (palette.getDarkVibrantSwatch() != null) {
temp[0] = palette.getDarkVibrantSwatch().getRgb();
temp[1] = palette.getDarkVibrantSwatch().getTitleTextColor();
temp[2] = palette.getDarkVibrantSwatch().getBodyTextColor();
} else if (palette.getDarkMutedSwatch() != null) {
temp[0] = palette.getDarkMutedSwatch().getRgb();
temp[1] = palette.getDarkMutedSwatch().getTitleTextColor();
temp[2] = palette.getDarkMutedSwatch().getBodyTextColor();
} else if (palette.getVibrantSwatch() != null) {
temp[0] = palette.getVibrantSwatch().getRgb();
temp[1] = palette.getVibrantSwatch().getTitleTextColor();
temp[2] = palette.getVibrantSwatch().getBodyTextColor();
} else if (palette.getDominantSwatch() != null) {
temp[0] = palette.getDominantSwatch().getRgb();
temp[1] = palette.getDominantSwatch().getTitleTextColor();
temp[2] = palette.getDominantSwatch().getBodyTextColor();
} else if (palette.getMutedSwatch() != null) {
temp[0] = palette.getMutedSwatch().getRgb();
temp[1] = palette.getMutedSwatch().getTitleTextColor();
temp[2] = palette.getMutedSwatch().getBodyTextColor();
} else {
temp[0] = ContextCompat.getColor(context, R.color.MaterialGrey);
temp[1] = Color.WHITE;
temp[2] = Color.WHITE;
}
return temp;
}
示例11: get6ColorFormBitmap
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
* 获得图片中出现最多的颜色
* 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;
}
示例12: extractSwatches
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
@NonNull
@WorkerThread
private List<Swatch> extractSwatches() {
final List<Swatch> colorSwatches = new ArrayList<>();
final List<Palette.Swatch> generatedSwatches = new ArrayList<>();
if (bitmap != null) {
final Palette palette;
if (noOfColors != 0) {
palette = Palette.from(bitmap).maximumColorCount(noOfColors).generate();
} else {
palette = Palette.from(bitmap).generate();
}
Palette.Swatch dominantSwatch = palette.getDominantSwatch();
Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
Palette.Swatch vibrantDarkSwatch = palette.getDarkVibrantSwatch();
Palette.Swatch vibrantLightSwatch = palette.getLightVibrantSwatch();
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
Palette.Swatch mutedDarkSwatch = palette.getDarkMutedSwatch();
Palette.Swatch mutedLightSwatch = palette.getLightMutedSwatch();
if (vibrantSwatch != null && mutedSwatch == null) {
mutedSwatch = vibrantSwatch;
} else if (vibrantSwatch == null && mutedSwatch != null) {
vibrantSwatch = mutedSwatch;
}
if (vibrantDarkSwatch != null && mutedDarkSwatch == null) {
mutedDarkSwatch = vibrantDarkSwatch;
} else if (vibrantDarkSwatch == null && mutedDarkSwatch != null) {
vibrantDarkSwatch = mutedDarkSwatch;
}
if (vibrantLightSwatch != null && mutedLightSwatch == null) {
mutedLightSwatch = vibrantLightSwatch;
} else if (vibrantLightSwatch == null && mutedLightSwatch != null) {
vibrantLightSwatch = mutedLightSwatch;
}
generatedSwatches.add(dominantSwatch);
generatedSwatches.add(vibrantSwatch);
generatedSwatches.add(vibrantDarkSwatch);
generatedSwatches.add(vibrantLightSwatch);
generatedSwatches.add(mutedSwatch);
generatedSwatches.add(mutedDarkSwatch);
generatedSwatches.add(mutedLightSwatch);
for (final Palette.Swatch paletteSwatch : generatedSwatches) {
colorSwatches.add(paletteSwatch != null ? new Swatch(paletteSwatch) : null);
}
recycleBitmap();
}
return colorSwatches;
}
示例13: 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) {}
};
}