I\'m using the android paging library to show search result items, is there any way I can clear/remove all the loaded result items, Calling Invalidate on live Paged List refresh
submitting null clear the currently loaded page list
productSearchResultItemAdapter.submitList(null)
Before invalidate, clear your list data item. Like we did in simple way:
list.clear();
adapter.notifyDataSetChanged();
In Java:
I cleared all items on in PagedListAdapter by calling invalidate() on DataSource instance like that
public void clear(){
movieDataSource.invalidate();
}
Add this method in your ViewModel then call it in your activity
movieViewModel.clear();
movieAdapter.notifyDataSetChanged();
Then Load any data you want
You can see how I made it in my project.
Here is the Link: https://github.com/Marwa-Eltayeb/MovieTrailer
If you're working with PagingDataAdapter, searchAdapter.submitData(lifecycle, PagingData.empty())
works