Fresco对Listview等快速滑动时停止加载

Fresco对Listview等快速滑动时停止加载

Fresco中在listview之类的快速滑动时停止加载,滑动停止后恢复加载:

1.设置图片请求是否开启
  1. // 暂停图片请求  
  2. public static void imagePause() {  
  3.     Fresco.getImagePipeline().pause();
  4. }
  5. // 恢复图片请求  
  6. public static void imageResume() {  
  7.     Fresco.getImagePipeline().resume();
  8. }
2.设置ListView滚动监听
  1. <pre name=“code” class=”java”><pre name=”code” class=”java”>mListView.setOnScrollListener(new AbsListView.OnScrollListener() {  
  2.     @Override  
  3.     public void onScrollStateChanged(AbsListView view, int scrollState) {  
  4.         switch(scrollState){  
  5.             case AbsListView.OnScrollListener.SCROLL_STATE_IDLE://空闲状态  
  6.                 imageResume();
  7.                 break;  
  8.             case AbsListView.OnScrollListener.SCROLL_STATE_FLING://滚动状态  
  9.                 imagePause();
  10.                 break;  
  11.             case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL://触摸后滚动  
  12.                 break;  
  13.         }
  14.     }
  15.     public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {  
  16.     }
  17. });

 

就是这么多,赶紧试试吧!