What's the simplest way to invalidate data retrieved by the paging library? I need to do that on logout. I've a DataSource.Factory and a DataSource that extends PageKeyedDataSource. Is it a good idea to call invalidate() on DataSource contructor? Will it work as expected?
Assuming you are using the Paging library with other Architecture Components, such as LiveData
and LifecycleOwner
and your screen is closed on logout, the DataSource
will be invalidated automatically.
If you don't, you still can invalidate it manually, calling
yourDataSource.invalidate();
After the invalidation, you won't be able to continue using the DataSource
. However, the views from the adapter will not be detached automatically, so if you want to clear them, you should either provide from your DataSource.Factory
a DataSource
that will return no data either just clear the RecyclerView.Adapter
manually.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.