本文整理汇总了Java中io.plaidapp.util.glide.GlideUtils类的典型用法代码示例。如果您正苦于以下问题:Java GlideUtils类的具体用法?Java GlideUtils怎么用?Java GlideUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GlideUtils类属于io.plaidapp.util.glide包,在下文中一共展示了GlideUtils类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResourceReady
import io.plaidapp.util.glide.GlideUtils; //导入依赖的package包/类
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
DataSource dataSource, boolean isFirstResource) {
final Bitmap bitmap = GlideUtils.getBitmap(resource);
if (bitmap == null) return false;
final int twentyFourDip = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
24, DribbbleShot.this.getResources().getDisplayMetrics());
Palette.from(bitmap)
.maximumColorCount(3)
.clearFilters() /* by default palette ignore certain hues
(e.g. pure black/white) but we don't want this. */
.setRegion(0, 0, bitmap.getWidth() - 1, twentyFourDip) /* - 1 to work around
https://code.google.com/p/android/issues/detail?id=191013 */
.generate(palette -> {
boolean isDark;
@ColorUtils.Lightness int lightness = ColorUtils.isDark(palette);
if (lightness == ColorUtils.LIGHTNESS_UNKNOWN) {
isDark = ColorUtils.isDark(bitmap, bitmap.getWidth() / 2, 0);
} else {
isDark = lightness == ColorUtils.IS_DARK;
}
if (!isDark) { // make back icon dark on light images
back.setColorFilter(ContextCompat.getColor(
DribbbleShot.this, R.color.dark_icon));
}
// color the status bar. Set a complementary dark color on L,
// light or dark color on M (with matching status bar icons)
int statusBarColor = getWindow().getStatusBarColor();
final Palette.Swatch topColor =
ColorUtils.getMostPopulousSwatch(palette);
if (topColor != null &&
(isDark || Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)) {
statusBarColor = ColorUtils.scrimify(topColor.getRgb(),
isDark, SCRIM_ADJUSTMENT);
// set a light status bar on M+
if (!isDark && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ViewUtils.setLightStatusBar(imageView);
}
}
if (statusBarColor != getWindow().getStatusBarColor()) {
imageView.setScrimColor(statusBarColor);
ValueAnimator statusBarColorAnim = ValueAnimator.ofArgb(
getWindow().getStatusBarColor(), statusBarColor);
statusBarColorAnim.addUpdateListener(animation -> getWindow().setStatusBarColor(
(int) animation.getAnimatedValue()));
statusBarColorAnim.setDuration(1000L);
statusBarColorAnim.setInterpolator(
getFastOutSlowInInterpolator(DribbbleShot.this));
statusBarColorAnim.start();
}
});
Palette.from(bitmap)
.clearFilters()
.generate(palette -> {
// color the ripple on the image spacer (default is grey)
shotSpacer.setBackground(
ViewUtils.createRipple(palette, 0.25f, 0.5f,
ContextCompat.getColor(DribbbleShot.this, R.color.mid_grey),
true));
// slightly more opaque ripple on the pinned image to compensate
// for the scrim
imageView.setForeground(
ViewUtils.createRipple(palette, 0.3f, 0.6f,
ContextCompat.getColor(DribbbleShot.this, R.color.mid_grey),
true));
});
// TODO should keep the background if the image contains transparency?!
imageView.setBackground(null);
return false;
}