use of rx.Subscription in project GeekNews by codeestX.
the class RepliesPresenter method getTopInfo.
@Override
public void getTopInfo(String topic_id) {
Subscription rxSubscription = mRetrofitHelper.fetchTopicInfo(topic_id).compose(RxUtil.<List<NodeListBean>>rxSchedulerHelper()).filter(new Func1<List<NodeListBean>, Boolean>() {
@Override
public Boolean call(List<NodeListBean> nodeListBeen) {
return nodeListBeen.size() > 0;
}
}).map(new Func1<List<NodeListBean>, NodeListBean>() {
@Override
public NodeListBean call(List<NodeListBean> nodeListBeen) {
return nodeListBeen.get(0);
}
}).subscribe(new CommonSubscriber<NodeListBean>(mView) {
@Override
public void onNext(NodeListBean nodeListBean) {
mView.showTopInfo(nodeListBean);
}
});
addSubscrebe(rxSubscription);
}
use of rx.Subscription in project GeekNews by codeestX.
the class SectionPresenter method getSectionData.
@Override
public void getSectionData() {
Subscription rxSubscription = mRetrofitHelper.fetchSectionListInfo().compose(RxUtil.<SectionListBean>rxSchedulerHelper()).subscribe(new CommonSubscriber<SectionListBean>(mView) {
@Override
public void onNext(SectionListBean sectionListBean) {
mView.showContent(sectionListBean);
}
});
addSubscrebe(rxSubscription);
}
use of rx.Subscription 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);
}
use of rx.Subscription 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);
}
use of rx.Subscription in project GeekNews by codeestX.
the class TechPresenter method registerEvent.
private void registerEvent() {
Subscription rxSubscription = RxBus.getDefault().toObservable(SearchEvent.class).compose(RxUtil.<SearchEvent>rxSchedulerHelper()).filter(new Func1<SearchEvent, Boolean>() {
@Override
public Boolean call(SearchEvent searchEvent) {
return searchEvent.getType() == currentType;
}
}).map(new Func1<SearchEvent, String>() {
@Override
public String call(SearchEvent searchEvent) {
return searchEvent.getQuery();
}
}).subscribe(new CommonSubscriber<String>(mView, "搜索失败") {
@Override
public void onNext(String s) {
queryStr = s;
getSearchTechData();
}
});
addSubscrebe(rxSubscription);
}
Aggregations