Livedata updating recycler view animation

from the CommonsWare Community archives

At August 19, 2019, 5:41pm, root-ansh asked:

So i have a roomdb app having a getAll() query which returns a livedata<List<Items>>. And i have an adapter/recyclerview combination to show these Items in which adapter has a setDataList(list<Items>) function , which gets called in the observer of the livedata.
Problem is that setDataList(list<Items>) can only call notifyDataSetChanged() to show actual changes , and this notifyDataSetChanged() does not create any cool recycler view insertion/deletion animations. i know notifyItemInserted() creates those animations I want, but how am i supposed to use that insetead of notifyDataSetChanged() ?

At August 19, 2019, 5:54pm, mmurphy replied:

The simple solution is to use the ListAdapter that is part of the RecyclerView library.

The complex solution is for you to compare the old and new lists yourself and figure out what to insert, replace, etc. ListAdapter handles all of that for you.