PagingDataAdapter
from Paging3 library internally manages two semantically different lists. adapter.snapshot()
returns a ItemSnapshotList
which includes placeholder elements. adapter.snapshot().items
return a List
which excludes placeholder items.
Now I had to update an element using it's id. Should find and pass the index based on ItemSnapshotList
or List
? Eg:
adapter.notifyItemChanged(
adapter.snapshot().indexOfFirst { it!!.id == id } // is this correct ?
adapter.snapshot().items.indexOfFirst { it.id == id } // or is this ?
, PAYLOAD_STATUS to Status.Active // payloads
)
I think it's impossible. Any change on your item,you need to destroy and rebuild the pagingList.
I think the best practice is change in your room, and the list observe the room.