Android中RecyclerView 滑动时图片加载的优化
作者:安卓星 时间:2021-07-29 09:58:12
RecyclerView 滑动时的优化处理,在滑动时停止加载图片,在滑动停止时开始加载图片,这里用了Glide.pause 和Glide.resume.这里为了避免重复设置增加开销,设置了一个标志变量来做判断。
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) {
sIsScrolling = true;
Glide.with(VipMasterActivity.this).pauseRequests();
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (sIsScrolling == true) {
Glide.with(VipMasterActivity.this).resumeRequests();
}
sIsScrolling = false;
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
});
来源:http://www.jianshu.com/p/ab597dabf35b
标签:recyclerview,滑动,优化
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java利用POI读取、写入Excel的方法指南
2023-11-23 15:39:23
![](https://img.aspxhome.com/file/2023/9/59899_0s.png)
java 多态性详解及常见面试题
2023-03-15 18:08:49
Java将String字符串带括号转成List的简单方法
2022-10-26 18:20:17
![](https://img.aspxhome.com/file/2023/5/66675_0s.png)
JAVA提高第八篇 动态代理技术
2023-07-19 07:13:12
![](https://img.aspxhome.com/file/2023/9/62829_0s.jpg)
Spring Security配置多个数据源并添加登录验证码的实例代码
2022-11-19 13:49:26
![](https://img.aspxhome.com/file/2023/6/69126_0s.png)
ActiveMQ安装及部署教程图解
2023-11-17 18:01:46
![](https://img.aspxhome.com/file/2023/3/59483_0s.png)
关于eclipse安装spring插件报错An error occurred while collecting items to be installed...解决方案
2023-05-27 03:34:45
![](https://img.aspxhome.com/file/2023/1/78351_0s.png)
浅谈Java线程Thread之interrupt中断解析
2023-07-19 09:25:11
![](https://img.aspxhome.com/file/2023/4/57684_0s.png)
C# Console利用mspaint打开图像并保存的方法
2023-07-05 16:15:43
Mybatis中的@Select、foreach用法
2023-06-05 00:07:20
Socket结合线程池使用实现客户端和服务端通信demo
2023-01-21 20:23:50
![](https://img.aspxhome.com/file/2023/5/86835_0s.jpg)
Java实体类不要使用基本类型的知识点总结
2023-02-21 10:04:49
Java中的ArrayList容量及扩容方式
2023-10-17 17:24:40
Gson之toJson和fromJson方法的具体使用
2021-07-20 16:28:47
![](https://img.aspxhome.com/file/2023/2/75512_0s.png)
java如何反编译jar包并修改class文件重新打包
2021-09-20 05:24:26
![](https://img.aspxhome.com/file/2023/3/81933_0s.jpg)
C# 4.0 大数的运算--BigInteger的应用详解
2022-02-02 06:40:05
![](https://img.aspxhome.com/file/2023/2/74832_0s.png)
详解如何将Spring Boot应用跑在Docker容器中
2023-04-25 08:08:58
![](https://img.aspxhome.com/file/2023/8/77158_0s.jpg)
c# 使用计时器和观察者模式实现报警推送需求
2022-05-24 02:16:46
![](https://img.aspxhome.com/file/2023/0/82160_0s.png)
My eclipse 端口占用(9360)问题解决办法
2023-05-19 02:34:32
![](https://img.aspxhome.com/file/2023/2/68542_0s.png)
Java接口和抽象类有什么区别
2021-08-21 07:01:18