Search in sources :

Example 1 with Subscription

use of rx.Subscription in project GeekNews by codeestX.

the class WechatPresenter method getWechatData.

@Override
public void getWechatData() {
    queryStr = null;
    currentPage = 1;
    Subscription rxSubscription = mRetrofitHelper.fetchWechatListInfo(NUM_OF_PAGE, currentPage).compose(RxUtil.<WXHttpResponse<List<WXItemBean>>>rxSchedulerHelper()).compose(RxUtil.<List<WXItemBean>>handleWXResult()).subscribe(new CommonSubscriber<List<WXItemBean>>(mView) {

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

Example 2 with Subscription

use of rx.Subscription in project GeekNews by codeestX.

the class WelcomePresenter method getWelcomeData.

@Override
public void getWelcomeData() {
    Subscription rxSubscription = mRetrofitHelper.fetchWelcomeInfo(RES).compose(RxUtil.<WelcomeBean>rxSchedulerHelper()).subscribe(new Action1<WelcomeBean>() {

        @Override
        public void call(WelcomeBean welcomeBean) {
            mView.showContent(welcomeBean);
            startCountDown();
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
            mView.jumpToMain();
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : WelcomeBean(com.codeest.geeknews.model.bean.WelcomeBean) Subscription(rx.Subscription)

Example 3 with Subscription

use of rx.Subscription in project GeekNews by codeestX.

the class ZhihuDetailPresenter method getDetailData.

@Override
public void getDetailData(int id) {
    Subscription rxSubscription = mRetrofitHelper.fetchDetailInfo(id).compose(RxUtil.<ZhihuDetailBean>rxSchedulerHelper()).subscribe(new CommonSubscriber<ZhihuDetailBean>(mView) {

        @Override
        public void onNext(ZhihuDetailBean zhihuDetailBean) {
            mData = zhihuDetailBean;
            mView.showContent(zhihuDetailBean);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : ZhihuDetailBean(com.codeest.geeknews.model.bean.ZhihuDetailBean) Subscription(rx.Subscription)

Example 4 with Subscription

use of rx.Subscription in project GeekNews by codeestX.

the class ZhihuDetailPresenter method getExtraData.

@Override
public void getExtraData(int id) {
    Subscription rxSubscription = mRetrofitHelper.fetchDetailExtraInfo(id).compose(RxUtil.<DetailExtraBean>rxSchedulerHelper()).subscribe(new CommonSubscriber<DetailExtraBean>(mView, "加载额外信息失败ヽ(≧Д≦)ノ") {

        @Override
        public void onNext(DetailExtraBean detailExtraBean) {
            mView.showExtraInfo(detailExtraBean);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : Subscription(rx.Subscription) DetailExtraBean(com.codeest.geeknews.model.bean.DetailExtraBean)

Example 5 with Subscription

use of rx.Subscription in project GeekNews by codeestX.

the class GoldPresenter method getGoldData.

@Override
public void getGoldData(String type) {
    mType = type;
    currentPage = 0;
    totalList.clear();
    Observable<List<GoldListBean>> list = mRetrofitHelper.fetchGoldList(type, NUM_EACH_PAGE, currentPage++).compose(RxUtil.<GoldHttpResponse<List<GoldListBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GoldListBean>>handleGoldResult());
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -3);
    Observable<List<GoldListBean>> hotList = mRetrofitHelper.fetchGoldHotList(type, new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()), NUM_HOT_LIMIT).compose(RxUtil.<GoldHttpResponse<List<GoldListBean>>>rxSchedulerHelper()).compose(RxUtil.<List<GoldListBean>>handleGoldResult());
    Subscription rxSubscription = Observable.concat(hotList, list).subscribe(new CommonSubscriber<List<GoldListBean>>(mView) {

        @Override
        public void onNext(List<GoldListBean> goldListBean) {
            if (isHotList) {
                isHotList = false;
                totalList.addAll(goldListBean);
            } else {
                isHotList = true;
                totalList.addAll(goldListBean);
                mView.showContent(totalList);
            }
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : GoldHttpResponse(com.codeest.geeknews.model.http.response.GoldHttpResponse) GoldListBean(com.codeest.geeknews.model.bean.GoldListBean) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) List(java.util.List) Subscription(rx.Subscription) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

Subscription (rx.Subscription)275 Test (org.junit.Test)82 List (java.util.List)66 Action0 (rx.functions.Action0)45 ArrayList (java.util.ArrayList)40 CompositeSubscription (rx.subscriptions.CompositeSubscription)40 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 Observable (rx.Observable)18 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)17 LinkedList (java.util.LinkedList)13 CommandStreamTest (com.netflix.hystrix.metric.CommandStreamTest)11 PlayList (io.github.ryanhoo.music.data.model.PlayList)11 View (android.view.View)10 MetaChangedEvent (io.hefuyi.listener.event.MetaChangedEvent)10 Bundle (android.os.Bundle)9 IOException (java.io.IOException)9 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)9