Search code examples
androidandroid-imageviewandroid-glide

How to load updated image instead of old image in recyclerview using glide library


I'm implemented Glide library to load image in ImageView it's working fine.

Dependency:

compile "com.github.bumptech.glide:glide:4.5.0"
annotationProcessor "com.github.bumptech.glide:compiler:4.5.0"
compile "jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0"

In Adapter:

                    Glide.with(context)
                    .load(ImageUrl)
                    .apply(bitmapTransform(new jp.wasabeef.glide.transformations.BlurTransformation(25)
                    ).diskCacheStrategy(DiskCacheStrategy.ALL))
                    .apply(new RequestOptions()
                            .placeholder(R.mipmap.ic_launcher))
                    .into(view);

Issue is that when I'm upload image and display in recyclerview and get URL from API then it's display previously added image from cache instead of new one. I just need to add new image in first position instead of refresh whole list.

By using this:

.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)

Above code refresh whole list because clear whole cache data. I just need to display new uploaded image in list.


Solution

  • Please set like this:-

    Glide.with(context)
            .load(img_url)
            .apply(new RequestOptions()
            .placeholder(R.mipmap.personal_pic)
            .diskCacheStrategy(DiskCacheStrategy.ALL))
            .into(iv_profile_pic);