Search in sources :

Example 1 with GankHttpResponse

use of com.codeest.geeknews.model.http.response.GankHttpResponse 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 2 with GankHttpResponse

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

the class TechPresenter method getMoreSearchGankData.

private void getMoreSearchGankData() {
    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.showMoreContent(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)

Aggregations

GankItemBean (com.codeest.geeknews.model.bean.GankItemBean)2 GankSearchItemBean (com.codeest.geeknews.model.bean.GankSearchItemBean)2 GankHttpResponse (com.codeest.geeknews.model.http.response.GankHttpResponse)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Subscription (rx.Subscription)2 Func1 (rx.functions.Func1)2