Fresco中在listview之类的快速滑动时停止加载,滑动停止后恢复加载:
1.设置图片请求是否开启
[java] view plain copy print?
- // 暂停图片请求
- public static void imagePause() {
- Fresco.getImagePipeline().pause();
- }
- // 恢复图片请求
- public static void imageResume() {
- Fresco.getImagePipeline().resume();
- }
2.设置ListView滚动监听
[java] view plain copy print?
- <pre name="code" class="java"><pre name="code" class="java">mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {
- switch(scrollState){
- case AbsListView.OnScrollListener.SCROLL_STATE_IDLE://空闲状态
- imageResume();
- break;
- case AbsListView.OnScrollListener.SCROLL_STATE_FLING://滚动状态
- imagePause();
- break;
- case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL://触摸后滚动
- break;
- }
- }
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- }
- });
就是这么多,赶紧试试吧!
时间: 2024-10-08 10:40:15