Search in sources :

Example 1 with Store

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

the class MainPresenter method loadStoreInfo.

@Override
public void loadStoreInfo() {
    Disposable disposable = mRepository.getStoreInfo(mRepository.getStoreId()).map(new Function<ApiResponse<Store>, Store>() {

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

        @Override
        public void onNext(Store store) {
            if (mView != null) {
                mView.showStoreInfo(store);
            }
        }

        @Override
        public void onError(Throwable t) {
            LogUtils.e(TAG, "loadStoreInfo error : " + t.getMessage());
        }

        @Override
        public void onComplete() {
        }
    });
    mDisposables.add(disposable);
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) Function(io.reactivex.functions.Function) Store(com.xinshang.audient.model.entities.Store) ApiResponse(com.xinshang.audient.model.entities.ApiResponse)

Example 2 with Store

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

the class SplashFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    LogUtils.i(TAG, "onViewCreated");
    setLoadingIndicator(false);
    mAdapter = new StoresAdapter(mContext);
    mAdapter.setListener(new StoresAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(Store store) {
            if (mPresenter != null) {
                mPresenter.persistenceStore(store);
            }
        }
    });
    mRecyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.addItemDecoration(new AudientItemDecoration(mContext));
    mRecyclerView.setAdapter(mAdapter);
    if (mPresenter != null) {
        mPresenter.subscribe();
    }
}
Also used : AudientItemDecoration(com.xinshang.audient.widget.AudientItemDecoration) Store(com.xinshang.audient.model.entities.Store) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 3 with Store

use of com.xinshang.audient.model.entities.Store 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

Store (com.xinshang.audient.model.entities.Store)3 ApiResponse (com.xinshang.audient.model.entities.ApiResponse)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 Disposable (io.reactivex.disposables.Disposable)2 Function (io.reactivex.functions.Function)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 StoreDataBean (com.xinshang.audient.model.entities.StoreDataBean)1 AudientItemDecoration (com.xinshang.audient.widget.AudientItemDecoration)1 List (java.util.List)1