Search in sources :

Example 6 with GankItemBean

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

the class TechPresenter method getGankData.

@Override
public void getGankData(String tech, int type) {
    queryStr = null;
    currentPage = 1;
    currentTech = tech;
    currentType = type;
    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.showContent(gankItemBeen);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Subscription(rx.Subscription) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean)

Example 7 with GankItemBean

use of com.codeest.geeknews.model.bean.GankItemBean 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)7 List (java.util.List)7 Subscription (rx.Subscription)7 ArrayList (java.util.ArrayList)5 GankSearchItemBean (com.codeest.geeknews.model.bean.GankSearchItemBean)2 GankHttpResponse (com.codeest.geeknews.model.http.response.GankHttpResponse)2 Func1 (rx.functions.Func1)2