'Should the index passed to notifyItemChanged consider placeholder items?

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
)


Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pnkj