[android] CollectionView logical children grows with Header/Footer #17012
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #16961
Debugging the
ItemsSourceDoesNotLeak()
test with a newHeader
andFooter
on Android, there was some very odd behavior...At the end of the test,
_logicalChildren
contained 9 items!Where I would expect it to contain 5?!?
It appears the problem is:
CollectionView.ItemsSource
changesWe notify Android's
RecyclerView
to refreshRecyclerView
callsOnCreateViewHolder()
for the header, footer, and all rows.CreateHeaderFooterViewHolder()
is called again for the header & footer.Duplicate
viewHolder.View
items are added as logical children.To fix this, an idea:
Create a new
internal ContainsLogicalChild()
methodCall this before adding the same
View
inCreateHeaderFooterViewHolder()
This isn't the best, because it will iterate over the
_logicalChildren
to decide if the list contains the view. But this is better than what strange behavior might result from this?