From 047c22d77ebb497db29cf329c2388274ee413f20 Mon Sep 17 00:00:00 2001 From: Payne Miller Date: Tue, 27 Aug 2019 10:26:51 -0400 Subject: [PATCH] Fix cancelAll() termination condition The method cancellAll() was using the field maxPreload to determine when the for loop should terminate, which was always off by one compared to the size of the preloadTargetQueue, and therefore, not all the pre-loaded requests would be canceled. This issue was raised in https://github.com/bumptech/glide/issues/3693 --- library/src/main/java/com/bumptech/glide/ListPreloader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/bumptech/glide/ListPreloader.java b/library/src/main/java/com/bumptech/glide/ListPreloader.java index ba6e4f2088..5e19fc1201 100644 --- a/library/src/main/java/com/bumptech/glide/ListPreloader.java +++ b/library/src/main/java/com/bumptech/glide/ListPreloader.java @@ -219,7 +219,7 @@ private void preloadItem(@Nullable T item, int position, int perItemPosition) { } private void cancelAll() { - for (int i = 0; i < maxPreload; i++) { + for (int i = 0; i < preloadTargetQueue.queue.size(); i++) { requestManager.clear(preloadTargetQueue.next(0, 0)); } }