鉴于一个场景,如果我们快速滚动列表,滑行应该取消 图像请求远离焦点的视图。滑翔如何做到这一点?我经常搜索,但找不到任何实质内容。
答案 0 :(得分:0)
使用 //滚动开始。
Glide.with(this).pauseRequests();
... //滚动停止。
Glide.with(this).resumeRequests();
表示
答案 1 :(得分:0)
您必须覆盖 recyclerView 的 onScrollStateChanged
,以便在滚动时可以检测视图是否移动并应用如下操作
setOnScrollListener(new AbsListView.OnScrollListener() {
@Override public void onScrollStateChanged(AbsListView view, int scrollState) {
switch (scrollState) {
case SCROLL_STATE_IDLE: // The view is not scrolling.
case SCROLL_STATE_TOUCH_SCROLL: // The user is scrolling using touch, and their finger is still on the screen
Glide.with(...).resumeRequests(); // resume glide requests
break;
case SCROLL_STATE_FLING: // The user had previously been scrolling using touch and had performed a fling
Glide.with(...).pauseRequests(); // pause glide requests
break;
}
}
});