/** * Lifecycle callback that unregisters for connectivity events (if the * android.permission.ACCESS_NETWORK_STATE permission is present) and pauses in progress loads. */ @Override public synchronized void onStop() { pauseRequests(); targetTracker.onStop(); }
@Override public void runTest() { manager.pauseRequests(); } });
/** * Performs {@link #pauseRequests()} recursively for all managers that are contextually descendant * to this manager based on the Activity/Fragment hierarchy: * * <ul> * <li>When pausing on an Activity all attached fragments will also get paused. * <li>When pausing on an attached Fragment all descendant fragments will also get paused. * <li>When pausing on a detached Fragment or the application context only the current * RequestManager is paused. * </ul> * * <p>Note, on pre-Jelly Bean MR1 calling pause on a Fragment will not cause child fragments to * pause, in this case either call pause on the Activity or use a support Fragment. */ // Public API. @SuppressWarnings({"WeakerAccess", "unused"}) public synchronized void pauseRequestsRecursive() { pauseRequests(); for (RequestManager requestManager : treeNode.getDescendants()) { requestManager.pauseRequests(); } }
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); // Log.d(">>> Picker >>>", "dy = " + dy); if (Math.abs(dy) > SCROLL_THRESHOLD) { mGlideRequestManager.pauseRequests(); } else { resumeRequestsIfNotDestroyed(); } } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if(newState == RecyclerView.SCROLL_STATE_IDLE){ Glide.with(MainActivity.this).resumeRequests(); }else{ Glide.with(MainActivity.this).pauseRequests(); } } });
@Test public void testPauseRequestsPausesRequests() { manager.pauseRequests(); verify(requestTracker).pauseRequests(); }
@Test public void testApplicationRequestManagerIsNotReResumedAfterFirstRetrieval() { RequestManager manager = retriever.get(RuntimeEnvironment.application); manager.pauseRequests(); manager = retriever.get(RuntimeEnvironment.application); assertTrue(manager.isPaused()); }
/** * Lifecycle callback that unregisters for connectivity events (if the android.permission.ACCESS_NETWORK_STATE * permission is present) and pauses in progress loads. */ @Override public void onStop() { pauseRequests(); }
@Override public void pause(Context context) { getRequestManager(context).pauseRequests(); }
/** * Performs {@link #pauseRequests()} recursively for all managers that are contextually descendant * to this manager based on the Activity/Fragment hierarchy: * * <ul> * <li>When pausing on an Activity all attached fragments will also get paused. * <li>When pausing on an attached Fragment all descendant fragments will also get paused. * <li>When pausing on a detached Fragment or the application context only the current RequestManager is paused. * </ul> * * <p>Note, on pre-Jelly Bean MR1 calling pause on a Fragment will not cause child fragments to pause, in this * case either call pause on the Activity or use a support Fragment. */ public void pauseRequestsRecursive() { Util.assertMainThread(); pauseRequests(); for (RequestManager requestManager : treeNode.getDescendants()) { requestManager.pauseRequests(); } }
/** * 取消所有正在下载或等待下载的任务。 */ public static void cancelAllTasks(Context context) { Glide.with(context).pauseRequests(); }
@Override public void onGlideShouldPauseRequests() { Glide.with(context).pauseRequests(); }
/** * 暂停请求 正在滚动的时候 * * @param context */ public void pauseRequests(Context context) { Glide.with(context).pauseRequests(); }
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); lastVisibleItem = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition(); Glide.with(getActivity()).pauseRequests(); } });
/** * Lifecycle callback that unregisters for connectivity events (if the * android.permission.ACCESS_NETWORK_STATE permission is present) and pauses in progress loads. */ @Override public void onStop() { pauseRequests(); targetTracker.onStop(); }
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); Glide.with(getActivity()).pauseRequests(); lastVisibleItem = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition(); } });
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); lastVisibleItem = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition(); Glide.with(getActivity()).pauseRequests(); } });
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE) { Glide.with(MainActivity.this).resumeRequests(); } else { Glide.with(MainActivity.this).pauseRequests(); } }
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) { Glide.with(context).pauseRequests(); } else if (newState == RecyclerView.SCROLL_STATE_IDLE) { Glide.with(context).resumeRequests(); } } }
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); EdgeEffectUtil.forRecyclerView(recyclerView, edgeColor); if (newState == RecyclerView.SCROLL_STATE_IDLE) { Glide.with(mApp).resumeRequests(); } else { // dragging or settling Glide.with(mApp).pauseRequests(); } } });