3

I would like to filter data from the current response in Paging 3 using PagingRx. I have tried as mention in Paging Documentation

Used Libraries

def paging_version = "3.0.1"
    //Paging
    implementation "androidx.paging:paging-runtime:$paging_version"
    // alternatively - without Android dependencies for tests
    testImplementation "androidx.paging:paging-common:$paging_version"
    // RxJava3
    implementation "androidx.paging:paging-rxjava3:$paging_version"

I have tried to filter responses in MyViewModel class as mention in the documentation.

// Type is Flowable<PagingData<User>>.
    PagingRx.getFlowable(pager)
      .map(pagingData ->
        pagingData.filter(user -> !user.isHiddenFromUi())
      )
    }

Now the problem is I didn't found any filter option under map. Please have look and let me know how to fix this issue.

1 Answers1

1

The paging3 documentation is very bad for java. The code samples provided for transforming data using java will never work because the map and filter are placed under a class called PagingDataTransforms.kt. I have attached the correct code sample below,

PagingRx.getFlowable(pager)
  .map(pagingData -> PagingDataTransforms.filter(pagingData, 
       Executors.newSingleThreadExecutor(), 
       user -> !user.isHiddenFromUi()));
Zahra
  • 2,231
  • 3
  • 21
  • 41