How to show loader again when using paging Library for Filter/Sort

Viewed 50
enter code here

//constructor
   ProductsViewModel(String seoUnique) {
      // getting our data source factory
      ProductsDataSourceFactory productsDataSourceFactory = new ProductsDataSourceFactory(seoUnique, 
"");

    // getting the live data source from data source factory
    networkState = Transformations.switchMap(productsDataSourceFactory.getItemLiveDataSource(),
            ProductsDataSource::getProgressLiveStatus);

    // getting the total items from data source factory
    total = Transformations.switchMap(productsDataSourceFactory.getItemLiveDataSource(),
            ProductsDataSource::getLiveTotal);

    // Getting PagedList config
    PagedList.Config pagedListConfig =
            (new PagedList.Config.Builder())
                    .setEnablePlaceholders(false)
                    .setPageSize(ProductsDataSource.PAGE_SIZE).build();

    // Building the paged list
    itemPagedList = Transformations.switchMap(filter, input -> {
        if (input == null || input.isEmpty()) {
            return (new LivePagedListBuilder(productsDataSourceFactory, pagedListConfig)).build();
        } else {
            return (new LivePagedListBuilder(new ProductsDataSourceFactory(seoUnique, input), pagedListConfig)).build();
        }
    });
}

loader showing with ProductsDataSourceFactory constructor instance, but when filter is not empty it is not showing any loader coz in filter i not use productsDataSourceFactory constructor instance.

Please give any solution

Thanks in advance.

0 Answers
Related