本文整理汇总了Java中android.support.v7.graphics.Palette.getVibrantColor方法的典型用法代码示例。如果您正苦于以下问题:Java Palette.getVibrantColor方法的具体用法?Java Palette.getVibrantColor怎么用?Java Palette.getVibrantColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.graphics.Palette
的用法示例。
在下文中一共展示了Palette.getVibrantColor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateHotseatPalette
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
* The hotseat's color is defined as follows:
* - 12% black for super light wallpaper
* - 18% white for super dark
* - 25% white otherwise
*/
void updateHotseatPalette(Palette hotseatPalette) {
int hotseatColor;
int vibrantColor;
if (hotseatPalette != null) {
int extractedVibrantColor = hotseatPalette.getVibrantColor(ExtractedColors.DEFAULT_COLOR);
if (ExtractionUtils.isSuperLight(hotseatPalette)) {
hotseatColor = ColorUtils.setAlphaComponent(Color.BLACK, (int) (0.12f * 255));
vibrantColor = ColorUtils.setAlphaComponent(extractedVibrantColor, (int) (0.12f * 255));
} else if (ExtractionUtils.isSuperDark(hotseatPalette)) {
hotseatColor = ColorUtils.setAlphaComponent(Color.WHITE, (int) (0.18f * 255));
vibrantColor = ColorUtils.setAlphaComponent(extractedVibrantColor, (int) (0.18f * 255));
} else {
hotseatColor = ColorUtils.setAlphaComponent(Color.WHITE, (int) (0.25f * 255));
vibrantColor = ColorUtils.setAlphaComponent(extractedVibrantColor, (int) (0.25f * 255));
}
setColorAtIndex(HOTSEAT_INDEX, hotseatColor);
setColorAtIndex(VIBRANT_INDEX, vibrantColor);
}
}
示例2: onGenerated
import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
* Called when the {@link Palette} has been generated.
*
* @param palette
*/
@Override
public void onGenerated(Palette palette) {
int color;
if((color = palette.getDominantColor(0)) != 0) {
mFrameLayout.setBackgroundColor(color);
}
else if((color = palette.getVibrantColor(0)) != 0) {
mFrameLayout.setBackgroundColor(color);
}
else if((color = palette.getDarkVibrantColor(0)) != 0) {
mFrameLayout.setBackgroundColor(color);
}
else if((color = palette.getDarkMutedColor(0)) != 0) {
mFrameLayout.setBackgroundColor(color);
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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();
}
});
}
}
示例8: 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);
}
}
示例9: 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) {}
};
}