当前位置:网站首页>After the image is updated, Glide loading is still the original image problem
After the image is updated, Glide loading is still the original image problem
2022-08-01 05:19:00 【Talents and learning are shallow, hard work】
reason
Glide cannot update the image due to cache when loading the same URL
Workaround
1, remove cache
If it is a local image, you can cancel the cache, which is a relatively simple operation:
.skipMemoryCache(true) // don't use memory cache.diskCacheStrategy(DiskCacheStrategy.NONE) // don't use disk cache.into(imageView);
2, using signature
Regardless of the local image network image, another method can be used, that is to use Glide's method .signature(Key signature), by creating a signature, and then changing the signature when the image is updated to achieve the effect of reloading.The signature can be a String or the time when the image is updated
Glide.with(getActivity()).load(urlString).signature(new ObjectKey(DateTimeUtil.GetNowTime()))//You can also use system milliseconds System.currentTimeMillis().into(portrait);
Note: The new StringSignature() class in Glide 4.0 is no longer supported and needs to be changed to new ObjectKey()
Tools used
public class DateTimeUtil {public static String GetNowTime() {SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date curDate = new Date(System.currentTimeMillis());// Get the current timeString str = formatter.format(curDate);return str;}}
边栏推荐
- Use controls as brushes to get bitmap code records
- typescript26 - literal types
- SL-12/2过流继电器
- PAT乙级 1001 害死人不偿命的(3n+1)猜想
- Selenium:上传、下载文件
- pytroch、tensorflow对比学习—功能组件(数据管道、回调函数、特征列处理)
- Seleniu:元素常用操作
- (Codeforce 757) E. Bash Plays with Functions
- (Codeforce 757)E. Bash Plays with Functions(积性函数)
- 关于给Qt做一个软件初始化的进度条
猜你喜欢
随机推荐
WPF项目-初步了解数据绑定 binding
Robot_Framework:断言
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
WPF入门项目必知必会-初步了解数据绑定 binding
Selenium:表单切换
pytorch、tensorflow对比学习—功能组件(优化器、评估指标、Module管理)
Seleniu:元素常用操作
WebSocket实现聊天功能
The difference between scheduleWithFixedDelay and scheduleAtFixedRate
Selenium:弹窗处理
state compressed dp
牛客多校2022第四场A,H,K,N
剑指 Offer 68 - II. 二叉树的最近公共祖先
请求/响应拦截器写法
AspNet.WebApi.Owin 自定义Token请求参数
4D line-by-line analysis and implementation of Transformer, and German translation into English (3)
万字逐行解析与实现Transformer,并进行德译英实战(一)
pytroch、tensorflow对比学习—专栏介绍
2022年超全的Android面经(附含面试题|进阶资料)
Qt Widget 项目对qml的加载实例