Search in sources :

Example 1 with GoldHttpResponse

use of com.codeest.geeknews.model.http.response.GoldHttpResponse in project GeekNews by codeestX.

the class GoldPresenter method getGoldData.

@Override
public void getGoldData(String type) {
    mType = type;
    currentPage = 0;
    totalList.clear();
    Observable<List<GoldListBean>> list = mRetrofitHelper.fetchGoldList(type, NUM_EACH_PAGE, currentPage++).compose(RxUtil.<GoldHttpResponse<List<GoldListBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GoldListBean>>handleGoldResult());
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -3);
    Observable<List<GoldListBean>> hotList = mRetrofitHelper.fetchGoldHotList(type, new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()), NUM_HOT_LIMIT).compose(RxUtil.<GoldHttpResponse<List<GoldListBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GoldListBean>>handleGoldResult());
    Subscription rxSubscription = Observable.concat(hotList, list).subscribe(new CommonSubscriber<List<GoldListBean>>(mView) {

        @Override
        public void onNext(List<GoldListBean> goldListBean) {
            if (isHotList) {
                isHotList = false;
                totalList.addAll(goldListBean);
            } else {
                isHotList = true;
                totalList.addAll(goldListBean);
                mView.showContent(totalList);
            }
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : GoldHttpResponse(com.codeest.geeknews.model.http.response.GoldHttpResponse) GoldListBean(com.codeest.geeknews.model.bean.GoldListBean) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) List(java.util.List) Subscription(rx.Subscription) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with GoldHttpResponse

use of com.codeest.geeknews.model.http.response.GoldHttpResponse in project GeekNews by codeestX.

the class GoldPresenter method getGoldData.

@Override
public void getGoldData(String type) {
    mType = type;
    currentPage = 0;
    totalList.clear();
    Flowable<List<GoldListBean>> list = mDataManager.fetchGoldList(type, NUM_EACH_PAGE, currentPage++).compose(RxUtil.<GoldHttpResponse<List<GoldListBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GoldListBean>>handleGoldResult());
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -3);
    Flowable<List<GoldListBean>> hotList = mDataManager.fetchGoldHotList(type, new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()), NUM_HOT_LIMIT).compose(RxUtil.<GoldHttpResponse<List<GoldListBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GoldListBean>>handleGoldResult());
    addSubscribe(Flowable.concat(hotList, list).subscribeWith(new CommonSubscriber<List<GoldListBean>>(mView) {

        @Override
        public void onNext(List<GoldListBean> goldListBean) {
            if (isHotList) {
                isHotList = false;
                totalList.addAll(goldListBean);
            } else {
                isHotList = true;
                totalList.addAll(goldListBean);
                mView.showContent(totalList);
            }
        }
    }));
}
Also used : GoldHttpResponse(com.codeest.geeknews.model.http.response.GoldHttpResponse) GoldListBean(com.codeest.geeknews.model.bean.GoldListBean) CommonSubscriber(com.codeest.geeknews.widget.CommonSubscriber) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) List(java.util.List) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

GoldListBean (com.codeest.geeknews.model.bean.GoldListBean)2 GoldHttpResponse (com.codeest.geeknews.model.http.response.GoldHttpResponse)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 List (java.util.List)2 CommonSubscriber (com.codeest.geeknews.widget.CommonSubscriber)1 Subscription (rx.Subscription)1