From a98b30161500a31fa09cb2655b013d591dc38361 Mon Sep 17 00:00:00 2001 From: Vignesh Venkat Date: Tue, 24 Sep 2024 09:31:25 -0700 Subject: [PATCH] GifDrawable: Call stop before notifying end to listeners In the current code, `GifDrawable` calls the `onAnimationEnd` callback first and then invokes `stop()` to end the animation. This behavior prevents the following use-case: An app wants to schedule another loop of the `GifDrawable` when the current loop ends (i.e.) calls `start()` from within the `onAnimationEnd()` callback. This doesn't work because `stop()` is called right after the onAnimationEnd() callback is complete. Reversing the order of these two calls to enable this use-case. --- .../java/com/bumptech/glide/load/resource/gif/GifDrawable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/bumptech/glide/load/resource/gif/GifDrawable.java b/library/src/main/java/com/bumptech/glide/load/resource/gif/GifDrawable.java index d62a48437c..8efcb9dc3b 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/gif/GifDrawable.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/gif/GifDrawable.java @@ -345,8 +345,8 @@ public void onFrameReady() { } if (maxLoopCount != LOOP_FOREVER && loopCount >= maxLoopCount) { - notifyAnimationEndToListeners(); stop(); + notifyAnimationEndToListeners(); } }