Search in sources :

Example 1 with GankItemBean

use of com.codeest.geeknews.model.bean.GankItemBean in project GeekNews by codeestX.

the class GirlPresenter method getMoreGirlData.

@Override
public void getMoreGirlData() {
    Subscription rxSubscription = mRetrofitHelper.fetchGirlList(NUM_OF_PAGE, ++currentPage).compose(RxUtil.<GankHttpResponse<List<GankItemBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GankItemBean>>handleResult()).subscribe(new CommonSubscriber<List<GankItemBean>>(mView) {

        @Override
        public void onNext(List<GankItemBean> gankItemBeen) {
            mView.showMoreContent(gankItemBeen);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : List(java.util.List) Subscription(rx.Subscription) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean)

Example 2 with GankItemBean

use of com.codeest.geeknews.model.bean.GankItemBean in project GeekNews by codeestX.

the class TechPresenter method getGirlImage.

@Override
public void getGirlImage() {
    Subscription rxSubscription = mRetrofitHelper.fetchRandomGirl(1).compose(RxUtil.<GankHttpResponse<List<GankItemBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GankItemBean>>handleResult()).subscribe(new CommonSubscriber<List<GankItemBean>>(mView, "加载封面失败") {

        @Override
        public void onNext(List<GankItemBean> gankItemBean) {
            mView.showGirlImage(gankItemBean.get(0).getUrl(), gankItemBean.get(0).getWho());
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Subscription(rx.Subscription) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean)

Example 3 with GankItemBean

use of com.codeest.geeknews.model.bean.GankItemBean in project GeekNews by codeestX.

the class TechPresenter method getSearchTechData.

private void getSearchTechData() {
    currentPage = 1;
    Subscription rxSubscription = mRetrofitHelper.fetchGankSearchList(queryStr, currentTech, NUM_OF_PAGE, currentPage).compose(RxUtil.<GankHttpResponse<List<GankSearchItemBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GankSearchItemBean>>handleResult()).map(new Func1<List<GankSearchItemBean>, List<GankItemBean>>() {

        @Override
        public List<GankItemBean> call(List<GankSearchItemBean> gankSearchItemBeen) {
            List<GankItemBean> newList = new ArrayList<>();
            for (GankSearchItemBean item : gankSearchItemBeen) {
                GankItemBean bean = new GankItemBean();
                bean.set_id(item.getGanhuo_id());
                bean.setDesc(item.getDesc());
                bean.setPublishedAt(item.getPublishedAt());
                bean.setWho(item.getWho());
                bean.setUrl(item.getUrl());
                newList.add(bean);
            }
            return newList;
        }
    }).subscribe(new CommonSubscriber<List<GankItemBean>>(mView) {

        @Override
        public void onNext(List<GankItemBean> gankItemBeen) {
            mView.showContent(gankItemBeen);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : GankHttpResponse(com.codeest.geeknews.model.http.response.GankHttpResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Subscription(rx.Subscription) Func1(rx.functions.Func1) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean) GankSearchItemBean(com.codeest.geeknews.model.bean.GankSearchItemBean)

Example 4 with GankItemBean

use of com.codeest.geeknews.model.bean.GankItemBean in project GeekNews by codeestX.

the class GirlPresenter method getGirlData.

@Override
public void getGirlData() {
    currentPage = 1;
    Subscription rxSubscription = mRetrofitHelper.fetchGirlList(NUM_OF_PAGE, currentPage).compose(RxUtil.<GankHttpResponse<List<GankItemBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GankItemBean>>handleResult()).subscribe(new CommonSubscriber<List<GankItemBean>>(mView) {

        @Override
        public void onNext(List<GankItemBean> gankItemBeen) {
            mView.showContent(gankItemBeen);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : List(java.util.List) Subscription(rx.Subscription) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean)

Example 5 with GankItemBean

use of com.codeest.geeknews.model.bean.GankItemBean in project GeekNews by codeestX.

the class TechPresenter method getMoreGankData.

@Override
public void getMoreGankData(String tech) {
    if (queryStr != null) {
        getMoreSearchGankData();
        return;
    }
    Subscription rxSubscription = mRetrofitHelper.fetchTechList(tech, NUM_OF_PAGE, ++currentPage).compose(RxUtil.<GankHttpResponse<List<GankItemBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GankItemBean>>handleResult()).subscribe(new CommonSubscriber<List<GankItemBean>>(mView, "加载更多数据失败ヽ(≧Д≦)ノ") {

        @Override
        public void onNext(List<GankItemBean> gankItemBeen) {
            mView.showMoreContent(gankItemBeen);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Subscription(rx.Subscription) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean)

Aggregations

GankItemBean (com.codeest.geeknews.model.bean.GankItemBean)8 List (java.util.List)8 Subscription (rx.Subscription)7 ArrayList (java.util.ArrayList)6 GankSearchItemBean (com.codeest.geeknews.model.bean.GankSearchItemBean)3 GankHttpResponse (com.codeest.geeknews.model.http.response.GankHttpResponse)2 Func1 (rx.functions.Func1)2 CommonSubscriber (com.codeest.geeknews.widget.CommonSubscriber)1