How To Update Single Item Using Paging 3 Library
I am trying to find a way to update single item in recycler view using PagingAdapter from Paging 3 library. I have found only one way with PagingAdapter.refresh() method. But this
Solution 1:
Currently, the only way to update the backing dataset is to invalidate and reload the list. This is generally an acceptably cheap option for layered sources that use a cached layer (either in db such as room or in memory), although there is ongoing work to support more granular updates (see https://issuetracker.google.com/160232968).
In terms of layered source for now, you'll need to move your network calls into a RemoteMediator
which you can register in Pager
's constructor, and cache your network fetches into either a DB like with Room (which can generate a PagingSource
implementation for you), or write an in-memory one yourself.
The codelab and DAC docs are a great resource for this, and have code samples to guide you!
Solution 2:
Example :
funmarkItemAsRead(position: Int) {
snapshot()[position].read = true
notifyItemChanged(position)
}
Solution 3:
(adapterComment.snapshot().items asMutableList<Model>)[position].likeStatus =0
adapterComment.notifyItemChanged(position)
Post a Comment for "How To Update Single Item Using Paging 3 Library"