use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project plaid by nickbutcher.
the class FeedAdapter method bindDribbbleShotHolder.
private void bindDribbbleShotHolder(final Shot shot, final DribbbleShotHolder holder, int position) {
final int[] imageSize = shot.images.bestSize();
Glide.with(host).load(shot.images.best()).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (!shot.hasFadedIn) {
holder.image.setHasTransientState(true);
final ObservableColorMatrix cm = new ObservableColorMatrix();
final ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
// just animating the color matrix does not invalidate the
// drawable so need this update listener. Also have to create a
// new CMCF as the matrix is immutable :(
holder.image.setColorFilter(new ColorMatrixColorFilter(cm));
}
});
saturation.setDuration(2000L);
saturation.setInterpolator(getFastOutSlowInInterpolator(host));
saturation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
holder.image.clearColorFilter();
holder.image.setHasTransientState(false);
}
});
saturation.start();
shot.hasFadedIn = true;
}
return false;
}
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
}).placeholder(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]).diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter().override(imageSize[0], imageSize[1]).into(new DribbbleTarget(holder.image, false));
// need both placeholder & background to prevent seeing through shot as it fades in
holder.image.setBackground(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]);
holder.image.showBadge(shot.animated);
// need a unique transition name per shot, let's use it's url
holder.image.setTransitionName(shot.html_url);
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project CloudReader by youlookwhat.
the class MovieDetailActivity method setImgHeaderBg.
/**
* 加载titlebar背景
*/
private void setImgHeaderBg() {
if (subjectsBean != null) {
// 高斯模糊背景 原来 参数:12,5 23,4
Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 23, 4)).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
binding.titleToolBar.setBackgroundColor(Color.TRANSPARENT);
binding.ivTitleHeadBg.setImageAlpha(0);
binding.ivTitleHeadBg.setVisibility(View.VISIBLE);
return false;
}
}).into(binding.ivTitleHeadBg);
}
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project LookLook by xinghongfei.
the class MeiziAdapter method bindViewHolderNormal.
private void bindViewHolderNormal(final MeiziViewHolder holder, final int position) {
final Meizi meizi = meiziItemes.get(holder.getAdapterPosition());
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startDescribeActivity(meizi, holder);
}
});
// holder.textView.setText("视频");
// holder.textView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// startDescribeActivity(meizi,holder);
// }
// });
Glide.with(mContext).load(meizi.getUrl()).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (!meizi.hasFadedIn) {
holder.imageView.setHasTransientState(true);
final ObservableColorMatrix cm = new ObservableColorMatrix();
final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
}
});
animator.setDuration(2000L);
animator.setInterpolator(new AccelerateInterpolator());
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
holder.imageView.clearColorFilter();
holder.imageView.setHasTransientState(false);
animator.start();
meizi.hasFadedIn = true;
}
});
}
return false;
}
}).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().into(new DribbbleTarget(holder.imageView, false));
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project LookLook by xinghongfei.
the class TopNewsAdapter method bindViewHolderNormal.
private void bindViewHolderNormal(final TopNewsViewHolder holder, final int position) {
final NewsBean newsBeanItem = topNewitems.get(holder.getAdapterPosition());
if (DBUtils.getDB(mContext).isRead(Config.TOPNEWS, newsBeanItem.getTitle(), 1)) {
holder.textView.setTextColor(Color.GRAY);
holder.sourceTextview.setTextColor(Color.GRAY);
} else {
holder.textView.setTextColor(Color.BLACK);
holder.sourceTextview.setTextColor(Color.BLACK);
}
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DBUtils.getDB(mContext).insertHasRead(Config.ZHIHU, newsBeanItem.getTitle(), 1);
holder.textView.setTextColor(Color.GRAY);
holder.sourceTextview.setTextColor(Color.GRAY);
startTopnewsActivity(newsBeanItem, holder);
}
});
holder.textView.setText(newsBeanItem.getTitle());
holder.sourceTextview.setText(newsBeanItem.getSource());
holder.linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startTopnewsActivity(newsBeanItem, holder);
}
});
Glide.with(mContext).load(newsBeanItem.getImgsrc()).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (!newsBeanItem.hasFadedIn) {
holder.imageView.setHasTransientState(true);
final ObservableColorMatrix cm = new ObservableColorMatrix();
final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
}
});
animator.setDuration(2000L);
animator.setInterpolator(new AccelerateInterpolator());
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
holder.imageView.clearColorFilter();
holder.imageView.setHasTransientState(false);
animator.start();
newsBeanItem.hasFadedIn = true;
}
});
}
return false;
}
}).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().override(widthPx, heighPx).into(new DribbbleTarget(holder.imageView, false));
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project easy by MehdiBenmesa.
the class MaterialViewPagerImageHelper method setImageUrl.
/**
* change the image with a fade
*
* @param urlImage
* @param fadeDuration TODO : remove Picasso
*/
public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) {
final float alpha = ViewCompat.getAlpha(imageView);
final ImageView viewToAnimate = imageView;
// fade to alpha=0
fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
super.onAnimationEnd(view);
// change the image when alpha=0
Glide.with(imageView.getContext()).load(urlImage).centerCrop().listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
// then fade to alpha=1
fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
if (imageLoadListener != null) {
imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap());
}
return false;
}
}).into(viewToAnimate);
}
});
}
Aggregations