0
  1. DataSource extends RxPagingSource
    @NotNull
        @Override
        public Single<LoadResult<Integer, L>> loadSingle(@NotNull LoadParams<Integer> params) {
            nextPageNumber = params.getKey();
            if (nextPageNumber == null) {
                nextPageNumber = 1;
            }
    
            return getApiRequest(nextPageNumber, params.getLoadSize())
                    .subscribeOn(Schedulers.io())
                    .map(d -> toLoadResult(params, d))
                    .onErrorReturn(LoadResult.Error::new);
        }
    
protected LoadResult<Integer, L> toLoadResult(LoadParams<Integer> params, D response) {}

  1. Handle datasource in ViewModel

    Flowable<PagingData<PojoPassengerData>> flowable = PagingRx.getFlowable(
                        new Pager<>(new PagingConfig(TOTAL_PAGES), () -> new FakeTestSource(mApiService)));
                PagingRx.cachedIn(flowable, viewModelScope);
    
                mCompositeDisposable.add(
                        flowable.subscribe(pagingData -> dataPagingData = pagingData));

  1. Handle in Fragment
     adapter.submitData(getViewLifeCycle(), mViewModel.dataPagingData);
  1. Not refresh data by called here
    private void onRefresh() {
            mViewModel.showSwipeRefresh();
            adapter.refresh();
        }

I'm using Paging3 (3.0.1 Latest) and setup with Recycler view.

Load more working Retry working (with is called as adapter.retry() )

NOTE: Setup paging in RxJava so comment based on that.

Thanks in advance.

Vijay Chaudhary
  • 228
  • 2
  • 12
  • Without adding buggy code, how we are supposed to help? Please understand [how to ask a good question](https://stackoverflow.com/help/how-to-ask) beforehand. Thank you! – Jay Jul 30 '21 at 10:57
  • Now you can understand better, Thanks for comment. – Vijay Chaudhary Aug 05 '21 at 05:54

0 Answers0