Search in sources :

Example 6 with ApiResponse

use of com.xinshang.audient.model.entities.ApiResponse 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)6 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)5 Disposable (io.reactivex.disposables.Disposable)5 Function (io.reactivex.functions.Function)5 List (java.util.List)4 ArrayList (java.util.ArrayList)3 Store (com.xinshang.audient.model.entities.Store)2 Comment (com.xinshang.audient.model.entities.Comment)1 CommentDataBean (com.xinshang.audient.model.entities.CommentDataBean)1 Feedback (com.xinshang.audient.model.entities.Feedback)1 StoreDataBean (com.xinshang.audient.model.entities.StoreDataBean)1 StoreSong (com.xinshang.audient.model.entities.StoreSong)1 Toplist (com.xinshang.audient.model.entities.Toplist)1 ToplistDataBean (com.xinshang.audient.model.entities.ToplistDataBean)1 ConnectException (java.net.ConnectException)1 ByteString (okio.ByteString)1