In Android paging library, how do I invalidate the subset of the dataset in a PagedList or a DataSource? I write PagedList or DataSource because I don't know which one I should call.
For example, I'm making a QA App called BufferOverflow.
I have a PageKeyedDataSource
that load data over the network. It support pagination by the index on the API. In that App, I have a Top Question screen that has "infinite" list of top questions. Of course, the top question is updated periodically.
How to:
- Update the dataset at page 1?
- Update the dataset at page 10?
I understand that the benefit of using PagedList is it will do a calculation on which item is new/old, using DiffUtil
. But, how do I tell it the dataset on certain key
or position
has changed?
Is what I'm asking impossible? Should I implement custom paging behaviour on my own?
Note:
- I don't want to invalidate all the data.
adapter.getCurrentList().getDataSource().invalidate();
This will invalidate the whole data on data source. While I just want to invalidate certain part of the data.
- I think API that I'm looking for is similar to RecyclerView.Adapter's
list.adapter.notifyItemChanged(0);
But of course, its not Adapter's responsibility to update the dataset. It's either on the PagedList
, DataSource
, or Dao classes..