Skip to content

Commit

Permalink
GifDrawable: Call stop before notifying end to listeners
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vigneshvg authored and kanelbulle committed Sep 24, 2024
1 parent a7351b0 commit a98b301
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ public void onFrameReady() {
}

if (maxLoopCount != LOOP_FOREVER && loopCount >= maxLoopCount) {
notifyAnimationEndToListeners();
stop();
notifyAnimationEndToListeners();
}
}

Expand Down

0 comments on commit a98b301

Please sign in to comment.