-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ViewHolders offscreen are not being recycled when adapter is updated #379
Comments
Thanks for filing this and my apologies for the late reply. |
Let us know if you need anything, or have questions about the issue @thagikura |
Hi, I checked the project and the behavior. Short answer: For now it's the intended behavior. Long answer: Let me explain. FlexboxLayoutManager clears the viewHolders (and FlexLines) starting from the first visible part to the end. E.g. Let's say I have following ViewHolders and FlexLines. And ViewHolders 5, 6 are the first visible view holders. [ 1 ][2][ 3 ] FlexLine 0 In that case, every time notifyDatasetChanged is called (onLayoutChildren is called in the LayoutManager), FlexboxLayoutManager clears the FlexLine from 2 to 6 and ViewHolder from 5 to 13. The reason for that behavior is that FlexboxLayoutManager can't predict which ViewHolders can be still reused after the first visible position (or the first position where a ViewHolder is updated). I hope the above can explain these behaviors.
Also to give an explanation about this
This is because when calculating the visible potion of the FlexLines and ViewHolders, FlexboxLayoutManager calculates a little ahead of actual visible potion otherwise it can't know how many ViewHolders the last visible FlexLine is able to have. |
Please let me if it answers your issues/questions. |
Hey thanks for the nice, in depth answer. I can totally understand clearing all the lines from current top edge of screen, but what I still don't understand is why we can't reuse the same ViewHolders for items 10,11,12 and 13? |
Oh sorry part of my explanation could be misinterpreted. Actually 10, 11, 12 and 13 are reused once it's created.
The actual behavior is like the following:
|
Issues and steps to reproduce
Expected behavior
Should reuse ViewHolders instead of recreating them. Switching to LinearLayoutManager shows this behavior.
Version of the flexbox library
0.3.0, 0.3.1
Link to code
https://github.com/keithsmyth/TestDealDetailsHarness
The text was updated successfully, but these errors were encountered: