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

How to replay the animation after a drawable resource is set to LottieAnimationView? #2467

Closed
oOJohn6Oo opened this issue Feb 26, 2024 · 0 comments · Fixed by #2468
Closed

Comments

@oOJohn6Oo
Copy link

oOJohn6Oo commented Feb 26, 2024

Link to fork with a repro in the issue-repro module
issue-repo, test APKs is in the release section.

Describe the bug

I can switch between normal Drawable and LottieDrawable with version 6.2.0, just like Twitter's Like button.

binding.animationView.setOnClickListener {
    if((it as LottieAnimationView).drawable is LottieDrawable){
        it.setImageDrawable(ContextCompat.getDrawable(this, R.mipmap.ic_launcher))
    }else{
        it.setAnimation(R.raw.heart)
        it.playAnimation()
    }
}

ba6e49004292b214acd59d32a8ec8806

private void setCompositionTask(LottieTask<LottieComposition> compositionTask) {
LottieResult<LottieComposition> result = compositionTask.getResult();
if (result != null && result.getValue() == composition) {
return;
}

Changes to #2441 prevent us from setting the same animation for LottieAnimationView, but it also prevents us from replaying the animation.

I tried set frame to 0 then playAnimation(), but it didn't work.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Open the app, the heart animation should start playing.
  2. Click the heart, it should changes to app logo with no animation.
  3. Click the logo, there is no change in the UI of version 6.3.0. Version 6.2.0 displays the "heart" animation and starts playing.

What I want to know

  1. Is this an intented behavior?
  2. How to implement this feature in version 6.3.0?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant