Fresco中在listview之类的快速滑动时停止加载,滑动停止后恢复加载:
1.设置图片请求是否开启
- // 暂停图片请求
- public static void imagePause() {
- Fresco.getImagePipeline().pause();
- }
- // 恢复图片请求
- public static void imageResume() {
- Fresco.getImagePipeline().resume();
- }
2.设置ListView滚动监听
- <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) {
- }
- });
就是这么多,赶紧试试吧!
本文转自 一点点征服 博客园博客,原文链接:http://www.cnblogs.com/ldq2016/p/6646761.html,如需转载请自行联系原作者