Skip to content
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

Mechanism for overriding notification behavior #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

c-b-h
Copy link

@c-b-h c-b-h commented Apr 29, 2021

onDistinctItems is called when the adapter receives new (distinct from
previous) items. This allows for changing the notification behavior
in a backward-compatible way e.g. from notifyDataSetChanged() to notifyItemRangeInserted()`.

Our app uses a custom ItemAnimator for insertions and with this change, we're able to call notifyItemRangeInserted when the adapter initially receives items and there by trigger an insert animation as can be observed in this clip:

notify_insert.mov

The current behavior is that notifyDataSetChanged() is called which for the first item will not trigger an insert animation. See clip for difference and notice the first item:

changed.mov

`onDistinctItems` is called when the adapter receives new (distinct from
 previous) `items`. This allows for changing the notification behavior
 in a backward-compatible way e.g. from `notifyDataSetChanged() to
 `notifyItemRangeInserted()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant