use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project LookLook by xinghongfei.
the class ZhihuAdapter method bindViewHolderNormal.
private void bindViewHolderNormal(final ZhihuViewHolder holder, final int position) {
final ZhihuDailyItem zhihuDailyItem = zhihuDailyItems.get(holder.getAdapterPosition());
if (DBUtils.getDB(mContext).isRead(Config.ZHIHU, zhihuDailyItem.getId(), 1))
holder.textView.setTextColor(Color.GRAY);
else
holder.textView.setTextColor(Color.BLACK);
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goDescribeActivity(holder, zhihuDailyItem);
}
});
holder.textView.setText(zhihuDailyItem.getTitle());
holder.linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goDescribeActivity(holder, zhihuDailyItem);
}
});
Glide.with(mContext).load(zhihuDailyItems.get(position).getImages()[0]).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 (!zhihuDailyItem.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();
zhihuDailyItem.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 CloudReader by youlookwhat.
the class SlideShadeViewActivity method setData.
/**
* 加载titlebar背景
*/
private void setData() {
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 CloudReader by youlookwhat.
the class TestActivity method setData.
private void setData() {
if (subjectsBean != null) {
// 高斯模糊背景
Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 12, 5)).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) {
mToolbar.setBackgroundColor(Color.TRANSPARENT);
binding.ivTitleBg.setImageAlpha(0);
binding.ivTitleBg.setVisibility(View.VISIBLE);
return false;
}
}).into(binding.ivTitleBg);
}
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project xabber-android by redsolution.
the class ChatMessageAdapter method setUpImage.
private void setUpImage(MessageItem messageItem, final Message messageHolder) {
messageHolder.messageImage.setVisibility(View.GONE);
if (!messageItem.isImage() || !SettingsManager.connectionLoadImages()) {
return;
}
if (messageItem.getFilePath() != null) {
boolean result = FileManager.loadImageFromFile(context, messageItem.getFilePath(), messageHolder.messageImage);
if (result) {
messageHolder.messageImage.setVisibility(View.VISIBLE);
messageHolder.messageText.setVisibility(View.GONE);
} else {
final String uniqueId = messageItem.getUniqueId();
final Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
MessageItem first = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, uniqueId).findFirst();
if (first != null) {
first.setFilePath(null);
}
}
});
}
} else {
final ViewGroup.LayoutParams layoutParams = messageHolder.messageImage.getLayoutParams();
Integer imageWidth = messageItem.getImageWidth();
Integer imageHeight = messageItem.getImageHeight();
if (imageWidth != null && imageHeight != null) {
FileManager.scaleImage(layoutParams, imageHeight, imageWidth);
Glide.with(context).load(messageItem.getText()).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
messageHolder.messageImage.setVisibility(View.GONE);
messageHolder.messageText.setVisibility(View.VISIBLE);
return true;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).into(messageHolder.messageImage);
messageHolder.messageImage.setVisibility(View.VISIBLE);
messageHolder.messageText.setVisibility(View.GONE);
} else {
final String uniqueId = messageItem.getUniqueId();
Glide.with(context).load(messageItem.getText()).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(final Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
final int width = resource.getWidth();
final int height = resource.getHeight();
if (width <= 0 || height <= 0) {
messageHolder.messageImage.setVisibility(View.GONE);
messageHolder.messageText.setVisibility(View.VISIBLE);
return;
}
final Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
MessageItem first = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, uniqueId).findFirst();
if (first != null) {
first.setImageWidth(width);
first.setImageHeight(height);
}
}
});
FileManager.scaleImage(layoutParams, height, width);
messageHolder.messageImage.setImageBitmap(resource);
messageHolder.messageImage.setVisibility(View.VISIBLE);
messageHolder.messageText.setVisibility(View.GONE);
}
});
}
}
}
use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project sbt-android by scala-android.
the class FeedAdapter method bindDribbbleShotView.
private void bindDribbbleShotView(final Shot shot, final DribbbleShotHolder holder) {
final BadgedFourThreeImageView iv = (BadgedFourThreeImageView) holder.itemView;
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) {
iv.setHasTransientState(true);
final ObservableColorMatrix cm = new ObservableColorMatrix();
ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
// new CMCF as the matrix is immutable :(
if (iv.getDrawable() != null) {
iv.getDrawable().setColorFilter(new ColorMatrixColorFilter(cm));
}
}
});
saturation.setDuration(2000);
saturation.setInterpolator(AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in));
saturation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
iv.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(R.color.background_dark).diskCacheStrategy(DiskCacheStrategy.ALL).into(new DribbbleTarget(iv, false));
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
iv.setTransitionName(iv.getResources().getString(R.string.transition_shot));
iv.setBackgroundColor(ContextCompat.getColor(host, R.color.background_light));
Intent intent = new Intent();
intent.setClass(host, DribbbleShot.class);
intent.putExtra(DribbbleShot.EXTRA_SHOT, shot);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(view, host.getString(R.string.transition_shot)), Pair.create(view, host.getString(R.string.transition_shot_background)));
host.startActivity(intent, options.toBundle());
}
});
}
Aggregations