-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Fix LayoutAnimation Android bug when adding and removing views at the same time #7959
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix LayoutAnimation Android bug when adding and removing views at the same time #7959
Conversation
cc @astreet |
@@ -352,6 +352,7 @@ public void manageChildren( | |||
arrayContains(tagsToDelete, viewToRemove.getId())) { | |||
// The view will be removed and dropped by the 'delete' layout animation | |||
// instead, so do nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment probably needs to be updated. Since do nothing now looks like doing something.
Kinda unfortunate we have to do this, but I don't see another easy way. Would be amazing if we could add an integration test for this case as well layout animation in general since it seems somewhat easy to break! |
I found other issues that this doesn't fix so I'll have to debug this more and find a better solution. We may want to consider disabling delete animations for now. |
Yes I saw those commit but the problem is that views get added at the wrong index when doing some more complex animations. I managed to fix some of the issues by removing views based on their tags instead of their index but this doesn't work for adding views. I'll have to figure out why the index passed to manageChildren are not good. I'm using this modified UIExplorer example to reproduce this issue https://gist.github.com/janicduplessis/211d78c5408ab17dee7ad2e381648a48 and also increasing the LayoutAnimation duration to make it more obvious. |
@janicduplessis do you have any updates for this pull request? It's been a while since the last update so wanted to check in and see if you've looked at the requested changes. |
Any news on this? I'm getting
When using LayoutAnimation on Android when removing and adding items to a wrapped row. |
Occasionally this too:
|
@janicduplessis still planning to ship this PR? |
I don't think I'll have time to work on this any time soon, sadly this PR didn't completely fix the issue and I couldn't figure out a way to have a proper fix. |
OK, I am going to close this pull request because it seems like everyone is stalled, but if someone wants to continue working on this then please feel free to spin it back up again! |
Similar to #7942 but for android
Fix a bug that happens when views are added during a delete layout animation. What happens is that the inserted view is not inserted at the proper index if the deleted view index is smaller than the inserted one. This is because the view is not immediately removed from the subviews array so we need to offset the insert index for each view that is going to be deleted with an animation and is before the inserted view.
Test plan (required)
Tested that this fixed the bug in an app where I noticed it, also tested the UIExplorer example to make sure LayoutAnimations still worked properly.