-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Animation does not play when startAnimation is called in onBindViewHolder of an existing view #1495
Comments
This is the workaround I'm using: + if (isAttachedToWindow && !rootView.containsView(this)) {
+ // This is a workaround for https://github.com/airbnb/lottie-android/issues/1495.
+ doOnPreDraw { playAnimation() }
+ return
+ } |
@DavidDTA This is a very tricky case due to the way RecyclerView manages views (as you have mentioned). I'm not sure what the best course of action is that wouldn't cause other problems. Any ideas? |
One option that feels hacky but might work is to override Another option may be Another option may be |
@DavidDTA Calling onVIsibilityChanged from onDraw would walk the entire parent view hierarchy on every draw call for all animations. If using |
I think |
I'm having the same issue described here and in #1284 |
function isShown() may return false because parent == null, but visiblity does not changed, so onVisibilityChanged() not be triggered, and 'playAnimationWhenShown' not used. There should be a better solution than post {} |
testView.post { testView.playAnimation() } |
Same issue for me. Instead of RecyclerView, I encountered this problem in ViewPager. It works when using "post". |
I re-checked the test in the description (thank you for that) after landing #1981 and the test now passes! |
Describe the bug
When calling
startAnimation
in aRecyclerView
'sonBindViewHolder
, the animation does not play. This issue was partially fixed in #1324, but that fix only handles the case when theLottieAnimationView
is first created, and not when it is rebound with different data.The cause of the issue appears to be that when
onBindViewHolder
is called, the view is in an unusual state where it is attached to the window, butisShown
is false because it has no parent.Steps To Reproduce
Here is a unit test that demonstrates the issue:
The text was updated successfully, but these errors were encountered: