Skip to content

Commit

Permalink
* Extracted a clearRequests() and re-used it in onStop() and onDestroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
osamaaftab committed Jun 21, 2023
1 parent 5837c55 commit 31d9ce3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions library/src/main/java/com/bumptech/glide/RequestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,11 @@ public synchronized void onStart() {
*/
@Override
public synchronized void onStop() {
pauseRequests();
targetTracker.onStop();
if (clearOnStop) {
for (Target<?> target : targetTracker.getAll()) {
clear(target);
}
targetTracker.clear();
clearRequests();
} else {
pauseRequests();
}
}

Expand All @@ -389,10 +387,7 @@ public synchronized void onStop() {
@Override
public synchronized void onDestroy() {
targetTracker.onDestroy();
for (Target<?> target : targetTracker.getAll()) {
clear(target);
}
targetTracker.clear();
clearRequests();
requestTracker.clearRequests();
lifecycle.removeListener(this);
lifecycle.removeListener(connectivityMonitor);
Expand Down Expand Up @@ -723,6 +718,13 @@ public void onLowMemory() {
// Nothing to add conditionally. See Glide#onTrimMemory for unconditional behavior.
}

private synchronized void clearRequests() {
for (Target<?> target : targetTracker.getAll()) {
clear(target);
}
targetTracker.clear();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {}

Expand Down

0 comments on commit 31d9ce3

Please sign in to comment.