Skip to content

Eventually think about if notifyDataSetChanged is necessary #1

@doncung

Description

@doncung

Not sure if you will eventually learn this in codepath, but notifyDataSetChanged is a heavy handed way of updating an adapter especially if you are dealing with lots of items.

If you happen to know for instance that you are adding only a single new item there is a method notifyItemInserted, etc... that let you control in a more nuanced manner. The advantage of using these more nuanced calls is that Android can animate them in for a more seamless experience.

If many things are changing at once you don't have to keep track yourself. Consider using DiffUtil to figure our difference between what is currently in the adapter and what you want to change it to. https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil

This is just something to consider for instance when you are thinking about your independent project and want to polish the experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions