homeViewModel.pagingDataFlow.subscribe(expensesPagingData -> {
expenseAdapter.submitData(getLifecycle(), expensesPagingData);
}, throwable -> Log.e(TAG, "onCreate: " + throwable.getMessage()));
// ViewModel
private void init() {
pagingDataFlow = homeRepository.init();
CoroutineScope coroutineScope = ViewModelKt.getViewModelScope(this);
PagingRx.cachedIn(pagingDataFlow, coroutineScope);
}
// Repository
public Flowable<PagingData<ExpensesModel>> init() {
// Define Paging Source
expensePagingSource = new ExpensePagingSource(feDataService);
// Create new Pager
Pager<Integer, ExpensesModel> pager = new Pager<Integer, ExpensesModel>(
new PagingConfig(10,
10,
false,
10,
100),
() -> expensePagingSource); // set paging source
// inti Flowable
pagingDataFlow = PagingRx.getFlowable(pager);
return pagingDataFlow;
}
I have tried to invalidate still not working.
public void invalidatePageSource() {
if (expensePagingSource != null) {
expensePagingSource.invalidate();
}
}
When refreshing the adapter using expenseAdapter.refresh() An instance of PagingSource was re-used when Pager expected to create a newinstance. Ensure that the pagingSourceFactory passed to Pager always returns a new instance of PagingSource. This my floawable object which I am using to get data.
Any help will be appreciated.