Search in sources :

Example 56 with Subscription

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);
}
Also used : NodeListBean(com.codeest.geeknews.model.bean.NodeListBean) List(java.util.List) Subscription(rx.Subscription) Func1(rx.functions.Func1)

Example 57 with Subscription

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);
}
Also used : SectionListBean(com.codeest.geeknews.model.bean.SectionListBean) Subscription(rx.Subscription)

Example 58 with Subscription

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);
}
Also used : List(java.util.List) Subscription(rx.Subscription) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean)

Example 59 with Subscription

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);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Subscription(rx.Subscription) GankItemBean(com.codeest.geeknews.model.bean.GankItemBean)

Example 60 with Subscription

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);
}
Also used : SearchEvent(com.codeest.geeknews.model.event.SearchEvent) Subscription(rx.Subscription) Func1(rx.functions.Func1)

Aggregations

Subscription (rx.Subscription)302 Test (org.junit.Test)82 List (java.util.List)75 CompositeSubscription (rx.subscriptions.CompositeSubscription)55 Action0 (rx.functions.Action0)45 ArrayList (java.util.ArrayList)41 CountDownLatch (java.util.concurrent.CountDownLatch)38 Func1 (rx.functions.Func1)24 AtomicReference (java.util.concurrent.atomic.AtomicReference)20 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)19 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)17 Observable (rx.Observable)17 LinkedList (java.util.LinkedList)13 CommandStreamTest (com.netflix.hystrix.metric.CommandStreamTest)11 PlayList (io.github.ryanhoo.music.data.model.PlayList)11 MetaChangedEvent (io.hefuyi.listener.event.MetaChangedEvent)10 View (android.view.View)9 IOException (java.io.IOException)9 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)8 Intent (android.content.Intent)7