本文整理匯總了Java中android.support.v7.graphics.Palette.getVibrantSwatch方法的典型用法代碼示例。如果您正苦於以下問題:Java Palette.getVibrantSwatch方法的具體用法?Java Palette.getVibrantSwatch怎麽用?Java Palette.getVibrantSwatch使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.graphics.Palette的用法示例。
在下文中一共展示了Palette.getVibrantSwatch方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: getColor
點讚 3
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");
}
}
開發者ID:htqqdd,項目名稱:music_player,代碼行數:27,
示例2: getColor
點讚 3
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;
}
開發者ID:aliumujib,項目名稱:Orin,代碼行數:22,
示例3: getBestPaletteSwatchFrom
點讚 3
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;
}
開發者ID:TheAndroidMaster,項目名稱:MediaNotification,代碼行數:20,
示例4: createRipple
點讚 2
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);
}
開發者ID:gejiaheng,項目名稱:Protein,代碼行數:32,
示例5: getSwatch
點讚 2
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;
}
開發者ID:TheAndroidMaster,項目名稱:MediaNotification,代碼行數:28,
示例6: getColor
點讚 2
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;
}
開發者ID:MSay2,項目名稱:Mire,代碼行數:37,
示例7: fromBitmapGetRgb
點讚 2
import android.support.v7.graphics.Palette; //導入方法依賴的package包/類
public int fromBitmapGetRgb(Bitmap bitmap) {
//Bitmap bitmap= BitmapFactory.decodeResource(getResources(), R.mipmap.img_video);
Palette palette = Palette.from(bitmap).generate();
//Palette.from(bitmap).maximumColorCount(32).addFilter();
if (palette.getVibrantSwatch() != null) {
Log.e(TAG, "fromBitmapGetRgb: 1"+palette.getVibrantSwatch().getRgb() );
return palette.getVibrantSwatch().getRgb();
}
if (palette.getLightMutedSwatch() != null) {
Log.e(TAG, "fromBitmapGetRgb: 2"+palette.getLightMutedSwatch().getRgb() );
return palette.getLightMutedSwatch().getRgb();
}
if (palette.getDarkVibrantSwatch() != null) {
Log.e(TAG, "fromBitmapGetRgb: 3"+palette.getDarkVibrantSwatch().getRgb() );
return palette.getDarkVibrantSwatch().getRgb();
}
if (palette.getDarkMutedSwatch() != null) {
Log.e(TAG, "fromBitmapGetRgb: 4"+palette.getDarkMutedSwatch().getRgb() );
return palette.getDarkMutedSwatch().getRgb();
}
if (palette.getDominantSwatch() != null) {
Log.e(TAG, "fromBitmapGetRgb: 5"+palette.getDominantSwatch().getRgb() );
return palette.getDominantSwatch().getRgb();
}
if (palette.getLightVibrantSwatch() != null) {
Log.e(TAG, "fromBitmapGetRgb: 6"+palette.getLightVibrantSwatch().getRgb() );
return palette.getLightVibrantSwatch().getRgb();
}
return Color.parseColor("#3F51B5");
}
開發者ID:xmlxin,項目名稱:ReplyMessage,代碼行數:31,
示例8: createRipple
點讚 2
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);
}
開發者ID:haihaio,項目名稱:AmenEye,代碼行數:31,
示例9: getAvailableColor
點讚 2
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;
}
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:39,
示例10: getAvailableColor
點讚 2
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;
}
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:30,
示例11: get6ColorFormBitmap
點讚 2
import android.support.v7.graphics.Palette; //導入方法依賴的package包/類
/**
* 獲得圖片中出現最多的顏色
* 0 活力顏色
* 1 亮的活力顏色
* 2 暗的活力顏色
* 3 柔和顏色
* 4 亮的柔和顏色
* 5 暗的柔和顏色
*/
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;
}
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:52,
示例12: extractSwatches
點讚 2
import android.support.v7.graphics.Palette; //導入方法依賴的package包/類
@NonNull
@WorkerThread
private List extractSwatches() {
final List colorSwatches = new ArrayList<>();
final List 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;
}
開發者ID:arunkumar9t2,項目名稱:chameleon-live-wallpaper,代碼行數:52,
示例13: getLightThemeTarget
點讚 2
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,
注:本文中的android.support.v7.graphics.Palette.getVibrantSwatch方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。