I have a list of image views and some of them will be frequently updated with a fixed url. By appending a timestamp query parameter in the end of the url. It works, but I found when it updates it will also clear the current content. Any way to prevent this?
// the one needed to update with timestamp appended
image += "?"+String.valueOf(System.currentTimeMillis());
Glide.with(mContext.getApplicationContext())
.load(image)
.error(R.drawable.default_avatar)
.centerCrop()
.crossFade()
.into(((VideoViewHolder) holder).img);
// the others don't need to update
Glide.with(mContext.getApplicationContext())
.load(image)
.error(R.drawable.default_avatar)
.centerCrop()
.crossFade()
.into(((VideoViewHolder) holder).img);
Note that the others without timestamp appended are all good.
Loading images with the unknown size If a loaded image happens to be smaller than the ImageView, Glide will unnecessarily expand original bitmap to match the size of the target view. One way to prevent it is to set scaleType=”centerInside” in the ImageView. That way loaded image won't expand beyond the original size.
Glide enables effective loading and caching of images. You can load images from a variety of sources such as files URIs, Android resources, bitmaps, drawables, etc. Just use the load() method to receive images. Image editing and more transformations.
To simply load an image to LinearLayout, we call the with() method of Glide class and pass the context, then we call the load() method, which contains the URL of the image to be downloaded and finally we call the into() method to display the downloaded image on our ImageView.
Glide is a library for showing and caching images in android and it's not usable for videos.
Try this
Glide
.with(context)
.load(filepath)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.dontAnimate()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap arg0, GlideAnimation<? super Bitmap> arg1) {
// TODO Auto-generated method stub
holder.mItemView.setImageBitmap(arg0);
}
});
If you're using Glide 3.x and wish to directly display the image without the small crossfade effect, call .dontAnimate() on the Glide request builder: for more read this : Glide — Placeholders & Fade Animations
Happy coding!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With