Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel loading tasks when a new animation is set #14

Merged
merged 1 commit into from
Nov 30, 2016

Conversation

ngsilverman
Copy link
Collaborator

Example repro steps:

view.setAnimation(...);
view.setAnimation(...);
view.setProgress(1f);
// Progress ends up being 0 after both animations are loaded

The first loading task would consume the progress setting of 1f, and so the second one would use the default of 0f. A similar effect could be achieved with playAnimation().

Copy link
Collaborator

@gpeal gpeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 with 2 comments

}

private void cancelLoaderTask() {
if (loaderTask != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also set the loader to null in the listener?

@@ -70,6 +70,7 @@ public void onCompositionLoaded(LottieComposition composition) {
private boolean setProgressWhenCompositionSet;
private boolean playAnimationWhenCompositionSet;

@Nullable private LottieComposition.Cancellable loaderTask;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we give this a more descriptive name? Maybe compositionLoder or something?

@ngsilverman ngsilverman merged commit a48910c into master Nov 30, 2016
@ngsilverman ngsilverman deleted the nsilverman-loader-fix branch November 30, 2016 01:03
This was referenced Dec 19, 2018
@wlj190785060 wlj190785060 mentioned this pull request Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants