Search in sources :

Example 1 with StoreDataBean

use of com.xinshang.audient.model.entities.StoreDataBean in project Audient by komamj.

the class SplashPresenter method loadStores.

@Override
public void loadStores() {
    if (mView.isActive()) {
        mView.setLoadingIndicator(true);
    }
    Disposable disposable = mRepository.getStores(true, 0, 20, null).map(new Function<ApiResponse<StoreDataBean>, List<Store>>() {

        @Override
        public List<Store> apply(ApiResponse<StoreDataBean> storeDataBeanApiResponse) throws Exception {
            return storeDataBeanApiResponse.data.stores;
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<Store>>() {

        @Override
        public void onNext(List<Store> stores) {
            if (mView.isActive()) {
                mView.showStores(stores);
            }
        }

        @Override
        public void onError(Throwable t) {
            LogUtils.e(TAG, "getStores error : " + t.getMessage());
            if (mView.isActive()) {
                mView.setLoadingIndicator(false);
            }
        }

        @Override
        public void onComplete() {
            if (mView.isActive()) {
                mView.setLoadingIndicator(false);
            }
        }
    });
    mDisposables.add(disposable);
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) Function(io.reactivex.functions.Function) StoreDataBean(com.xinshang.audient.model.entities.StoreDataBean) Store(com.xinshang.audient.model.entities.Store) List(java.util.List) ApiResponse(com.xinshang.audient.model.entities.ApiResponse)

Aggregations

ApiResponse (com.xinshang.audient.model.entities.ApiResponse)1 Store (com.xinshang.audient.model.entities.Store)1 StoreDataBean (com.xinshang.audient.model.entities.StoreDataBean)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1 Function (io.reactivex.functions.Function)1 List (java.util.List)1