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


Java Palette.getLightVibrantSwatch方法代码示例

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


在下文中一共展示了Palette.getLightVibrantSwatch方法的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");
    }
}
 
开发者ID:htqqdd,项目名称:music_player,代码行数:27,代码来源:ColorUtil.java

示例2: get2ColorFormBitmap

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
 * 获得图片中出现最多的颜色
 * 0 亮的活力颜色
 * 1 亮的柔和颜色
 */
public static void get2ColorFormBitmap(@NonNull Bitmap bitmap, int defaultColor, int[] colors) {

    if (colors.length != 2)
        return;

    Palette palette;
    palette = new Palette.Builder(bitmap).generate();

    Palette.Swatch swatch;
    int color;

    if ((swatch = palette.getLightVibrantSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[0] = color;

    if ((swatch = palette.getLightMutedSwatch()) != null)
        color = swatch.getRgb();
    else color = defaultColor;
    colors[1] = color;

}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:28,代码来源:ColorUtils.java

示例3: 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;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:22,代码来源:PhonographColorUtil.java

示例4: 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;
}
 
开发者ID:TheAndroidMaster,项目名称:MediaNotification,代码行数:20,代码来源:PaletteUtils.java

示例5: get4LightColorWithTextFormBitmap

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
/**
 * 获得图片中出现最多的颜色<br>
 * 0 亮的活力颜色<br>
 * 1 亮的活力颜色 对应适合的字体颜色<br>
 * 2 亮的柔和颜色<br>
 * 3 亮的柔和颜色 对应适合的字体颜色<br>
 */
public static void get4LightColorWithTextFormBitmap(@NonNull Bitmap bitmap, int defaultColor, int defaultTextColor, int[] colors) {

    if (colors.length != 4)
        return;

    Palette palette;
    palette = new Palette.Builder(bitmap).generate();

    Palette.Swatch swatch;
    int color = defaultColor;
    int textColor = defaultTextColor;

    if ((swatch = palette.getLightVibrantSwatch()) != null) {
        color = swatch.getRgb();
        textColor = swatch.getTitleTextColor();
    }
    colors[0] = color;
    colors[1] = textColor;

    color = defaultColor;
    textColor = defaultTextColor;

    if ((swatch = palette.getLightMutedSwatch()) != null) {
        color = swatch.getRgb();
        textColor = swatch.getTitleTextColor();
    }
    colors[2] = color;
    colors[3] = textColor;

}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:38,代码来源:ColorUtils.java

示例6: 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);
}
 
开发者ID:gejiaheng,项目名称:Protein,代码行数:32,代码来源:ViewUtils.java

示例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;
   }
 
开发者ID:MSay2,项目名称:Mire,代码行数:37,代码来源:PaletteUtils.java

示例8: setPalette

import android.support.v7.graphics.Palette; //导入方法依赖的package包/类
public void setPalette(final Palette palette) {
    if (palette.getLightMutedSwatch() != null) {
        setSwatch(palette.getLightMutedSwatch());
    } else if (palette.getLightVibrantSwatch() != null) {
        setSwatch(palette.getLightVibrantSwatch());
    } else if (palette.getDarkMutedSwatch() != null) {
        setSwatch(palette.getDarkMutedSwatch());
    } else if (palette.getDarkVibrantSwatch() != null) {
        setSwatch(palette.getDarkVibrantSwatch());
    }
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:12,代码来源:ColorizedCardView.java

示例9: fromBitmapGetRgb

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,代码来源:SystemUtil.java

示例10: 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);
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:31,代码来源:ViewUtil.java

示例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;

}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:52,代码来源:ColorUtils.java

示例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;
}
 
开发者ID:arunkumar9t2,项目名称:chameleon-live-wallpaper,代码行数:52,代码来源:Extractor.java

示例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) {}
	};
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:69,代码来源:ChannelActivity.java


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