This repository was archived by the owner on May 23, 2025. It is now read-only.
show placeholders for null items in database backed recyclerviews #5074
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.
When using the database as
PagingSource, it can happen that there are null items, e.g. when the user jumps to the top and the items are no longer in memory and need to be re-queried. We have ignored this fact until now, leading to subtle bugs where the adapter just shows a completely emptyViewHolder, or worse, a recycled ViewHolder that has not been updated and shows the wrong post. Usually these are only visible for a split second but it can take longer in some cases e.g. on slow devices.Here is how the placeholders look:
Note: I would prefer to turn this behavior with the null items off, but we tried that once and it led to even worse bugs: #4471