use of com.bumptech.glide.request.RequestListener 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.request.RequestListener 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.request.RequestListener in project Robot-Scouter by SUPERCILEX.
the class TeamDetailsDialog method updateUi.
private void updateUi() {
if (mMedia != null && mName != null && mNameEditText != null && mMediaCapture != null && mWebsiteEditText != null) {
Team team = mTeamHelper.getTeam();
mMediaLoadProgress.setVisibility(View.VISIBLE);
Glide.with(getContext()).load(team.getMedia()).apply(RequestOptions.circleCropTransform().error(R.drawable.ic_memory_grey_48dp).fallback(R.drawable.ic_memory_grey_48dp)).listener(new RequestListener<Drawable>() {
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
mMediaLoadProgress.setVisibility(View.GONE);
return false;
}
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
mMediaLoadProgress.setVisibility(View.GONE);
return false;
}
}).into(mMedia);
mName.setText(team.toString());
mNameEditText.setText(team.getName());
mMediaEditText.setText(team.getMedia());
mWebsiteEditText.setText(team.getWebsite());
}
}
use of com.bumptech.glide.request.RequestListener 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.request.RequestListener in project Shuttle by timusus.
the class ArtworkView method bindView.
@Override
public void bindView(ViewHolder holder) {
super.bindView(holder);
long time = System.currentTimeMillis();
holder.textContainer.setBackground(null);
holder.progressBar.setVisibility(View.VISIBLE);
holder.lineTwo.setText(null);
Glide.with(holder.itemView.getContext()).using(new TypeLoader(type, file), InputStream.class).from(ArtworkProvider.class).as(BitmapAndSize.class).sourceEncoder(new StreamEncoder()).decoder(new BitmapAndSizeDecoder(holder.itemView.getContext())).diskCacheStrategy(DiskCacheStrategy.NONE).load(artworkProvider).listener(new RequestListener<ArtworkProvider, BitmapAndSize>() {
@Override
public boolean onException(Exception e, ArtworkProvider model, Target<BitmapAndSize> target, boolean isFirstResource) {
if (glideListener != null) {
if (holder.itemView.getHandler() != null) {
holder.itemView.getHandler().postDelayed(() -> glideListener.onArtworkLoadFailed(ArtworkView.this), System.currentTimeMillis() + 1000 - time);
}
}
return false;
}
@Override
public boolean onResourceReady(BitmapAndSize resource, ArtworkProvider model, Target<BitmapAndSize> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).into(new ImageViewTarget<BitmapAndSize>(((ViewHolder) holder).imageView) {
@Override
protected void setResource(BitmapAndSize resource) {
holder.textContainer.setBackgroundResource(R.drawable.text_protection_scrim_reversed);
holder.progressBar.setVisibility(View.GONE);
holder.imageView.setImageBitmap(resource.bitmap);
holder.lineTwo.setText(String.format("%sx%spx", resource.size.width, resource.size.height));
}
});
holder.lineOne.setText(ArtworkModel.getTypeString(type));
if (type == ArtworkProvider.Type.FOLDER && file != null) {
holder.lineOne.setText(file.getName());
}
if (isCustom && file != null && file.getPath().contains("custom_artwork")) {
holder.lineOne.setText(holder.itemView.getContext().getString(R.string.artwork_type_custom));
}
holder.checkView.setVisibility(isSelected() ? View.VISIBLE : View.GONE);
}
Aggregations