Reputation: 472
I use Glide library in my Android project to update avatar from URL that comes in response from API.
The problem is that when I try to load different image (from different URL) to the same imageView
it shows me an image that was downloaded first time. (URL forming works fine, I tried it in browser and it shows the needed image)
Here is my code: EditProfileFragment.xml
public static final String IMAGE_BASE_URL = "http://myapi.com/img/";
String imageUrl = Const.IMAGE_BASE_URL + cb_getProfile.photo; //imageName.jpg
Glide.with(mContext)
.load(imageUrl)
.animate(R.anim.abc_fade_in)
.centerCrop()
.into(mImageView_photo);
Upvotes: 4
Views: 5663
Reputation: 472
Solved this problem by adding a StringSignature
when loading image from the URL.
Source
Glide.with(mContext)
.load(imageUrl)
.animate(R.anim.abc_fade_in)
.signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
.centerCrop()
.into(mImageView_photo)
;
Thanks to Yoav Sternberg.
Upvotes: 5