我正在从远程URL
将图像加载到带有Glide的ImageView
中。更新图像时,该URL中的内容会更改,但URL位置保持不变。 (这是预期的)。
例如。 https://www.the-android-app.com/userid/121.jpg
现在我使用此代码将图像显示到ImageView中。
Glide
.with(this)
.load(profilePicUrl) //this is in String format
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.skipMemoryCache(true)
.error(R.drawable.default_profile_pic)
.into(imgProfilePic);
当我更新我的个人资料图片时,Glide正在从Cache
加载相同的旧图片。我需要在获取新图像之前删除此URL
的缓存条目。
编辑:网址始终保持不变,只有其中的内容发生变化。我正在使用Glide 3.8.0
你可以尝试签名(new ObjectKey(System.currentTimeMillis()))
查看Custom cache invalidation了解更多信息。
例
GlideApp.with(this)
.load(imageUrl)
.signature(new ObjectKey(System.currentTimeMillis()))
.into(imageView);