当前位置: 首页>>代码示例>>Java>>正文


Java Schedulers类代码示例

本文整理汇总了Java中rx.schedulers.Schedulers的典型用法代码示例。如果您正苦于以下问题:Java Schedulers类的具体用法?Java Schedulers怎么用?Java Schedulers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Schedulers类属于rx.schedulers包,在下文中一共展示了Schedulers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanBleDevices

import rx.schedulers.Schedulers; //导入依赖的package包/类
private void scanBleDevices() {
    mScanSubscroption = mRxBleClient
            .scanBleDevices()
            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())
            .filter(rxBleScanResult -> {
                return FilterDeviceName.equals(rxBleScanResult.getBleDevice().getName());
            })
            .subscribe(rxBleScanResult -> {
                int position = DeviceContext.AddorUpdateDevice(rxBleScanResult.getBleDevice()
                                .getMacAddress(),
                        rxBleScanResult.getRssi());
                if (position >= 0)
                    mScanDevices.getAdapter().notifyItemChanged(position);
                else
                    mScanDevices.getAdapter().notifyDataSetChanged();
            }, this::onScanFailure);
}
 
开发者ID:KunYi,项目名称:SensorTag2Testing,代码行数:19,代码来源:MainActivity.java

示例2: onActivityCreated

import rx.schedulers.Schedulers; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mAccount = getArguments().getParcelable("account");
    mUserListsModel = new UserListsModel(mAccount);

    mSubscriptions.add(
            mUserListsModel
                    .lists()
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io())
                    .subscribe(new DefaultObserver<List<UserList>>() {
                        @Override
                        public void onNext(List<UserList> userLists) {
                            super.onNext(userLists);
                            mRecyclerView.setAdapter(new ListAdapter(getActivity(), mAccount, userLists));
                        }
                    })
    );
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:21,代码来源:UserListsFragment.java

示例3: loadData

import rx.schedulers.Schedulers; //导入依赖的package包/类
@Override
public void loadData()
{

    RetrofitHelper.getLiveAPI()
            .getLiveAppIndex()
            .compose(bindToLifecycle())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(liveAppIndexInfo -> {

                mLiveAppIndexAdapter.setLiveInfo(liveAppIndexInfo);
                finishTask();
            }, throwable -> {
                initEmptyView();
            });
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:18,代码来源:HomeLiveFragment.java

示例4: getRetrofit

import rx.schedulers.Schedulers; //导入依赖的package包/类
public static RetrofitInterface getRetrofit(String email, String password) {

        String credentials = email + ":" + password;
        String basic = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        httpClient.addInterceptor(chain -> {

            Request original = chain.request();
            Request.Builder builder = original.newBuilder()
                    .addHeader("Authorization", basic)
                    .method(original.method(),original.body());
            return  chain.proceed(builder.build());

        });

        RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());

        return new Retrofit.Builder()
                .baseUrl(Constants.BASE_URL)
                .client(httpClient.build())
                .addCallAdapterFactory(rxAdapter)
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(RetrofitInterface.class);
    }
 
开发者ID:EdwardAlexis,项目名称:Sistema-de-Comercializacion-Negocios-Jhordan,代码行数:26,代码来源:NetworkUtil.java

示例5: startScroll

import rx.schedulers.Schedulers; //导入依赖的package包/类
/**
 * 图片开始轮播
 */
private void startScroll()
{

    compositeSubscription = new CompositeSubscription();
    isStopScroll = false;
    Subscription subscription = Observable.timer(delayTime, TimeUnit.SECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(aLong -> {

                if (isStopScroll)
                    return;

                isStopScroll = true;
                viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
            });
    compositeSubscription.add(subscription);
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:22,代码来源:BannerView.java

示例6: getUserInfo

import rx.schedulers.Schedulers; //导入依赖的package包/类
public void getUserInfo() {

    RetrofitHelper.getAccountAPI()
        .getUserInfoById(mid)
        .compose(this.bindToLifecycle())
        .doOnSubscribe(this::showProgressBar)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(userInfo -> {

          mUserDetailsInfo = userInfo;
          finishTask();
        }, throwable -> {
          hideProgressBar();
        });
  }
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:17,代码来源:UserInfoDetailsActivity.java

示例7: doSubscribe

import rx.schedulers.Schedulers; //导入依赖的package包/类
public void doSubscribe() {
    subscription = Observable.just("Hello Reactive!").observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new Subscriber<String>() {
        @Override
        public void onCompleted() {
            Toast.makeText(MainActivity.this, "Finish Subscribing...", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(final Throwable e) {
            e.printStackTrace();
        }

        @Override
        public void onNext(final String s) {
            Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:budioktaviyan,项目名称:reactive-concept,代码行数:19,代码来源:MainActivity.java

示例8: initializeData

import rx.schedulers.Schedulers; //导入依赖的package包/类
private void initializeData() {

        application.getWebService()
                .getInteractionPosts(likeCounter, MySharedPreferences.getUserId(preferences), MySharedPreferences.getUserToken(preferences))
                .retryWhen(new RetryWithDelay(3,2000))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<PostSuperUserListModel>() {
                    @Override
                    public void onNext(PostSuperUserListModel response) {
                        showRecycleWithDataFilled(response);
                        progressFrame.setVisibility(View.GONE);
                    }
                    @Override
                    public void onError(Throwable e) {
                        progressFrame.setVisibility(View.GONE);
                        try {
                            Timber.e(e.getMessage());
                     //       Toast.makeText(UserSameCounterActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                        }catch (Exception ex){
                            ex.printStackTrace();
                        }
                    }
                });
    }
 
开发者ID:sciage,项目名称:FinalProject,代码行数:26,代码来源:UserSameCounterActivity.java

示例9: getBookListDetail

import rx.schedulers.Schedulers; //导入依赖的package包/类
@Override
public void getBookListDetail(String bookListId) {
    Subscription rxSubscription = bookApi.getBookListDetail(bookListId).subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<BookListDetail>() {
                @Override
                public void onCompleted() {
                    mView.complete();
                }

                @Override
                public void onError(Throwable e) {
                    LogUtils.e("getBookListDetail:" + e.toString());
                    mView.complete();
                }

                @Override
                public void onNext(BookListDetail data) {
                    mView.showBookListDetail(data);
                }
            });
    addSubscrebe(rxSubscription);
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:24,代码来源:SubjectBookListDetailPresenter.java

示例10: getBestComments

import rx.schedulers.Schedulers; //导入依赖的package包/类
@Override
public void getBestComments(String disscussionId) {
    Subscription rxSubscription = bookApi.getBestComments(disscussionId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<CommentList>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    LogUtils.e("getBestComments:" + e.toString());
                }

                @Override
                public void onNext(CommentList list) {
                    mView.showBestComments(list);
                }
            });
    addSubscrebe(rxSubscription);
}
 
开发者ID:zwmlibs,项目名称:BookReader-master,代码行数:24,代码来源:BookHelpDetailPresenter.java

示例11: getOrders

import rx.schedulers.Schedulers; //导入依赖的package包/类
public void getOrders(int page,int pageNum,String startTime,String endTime){
    checkViewAttached();
    RxUtil.unsubscribe(mGetOrdersSubscription);
    mGetOrdersSubscription = mDataManager.getOrderList(page,pageNum,startTime,endTime)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribe(new Subscriber<OrderResponse>() {
                @Override
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    getMvpView().showOrdersError();
                }

                @Override
                public void onNext(OrderResponse orderResponse) {
                    getMvpView().showOrders(orderResponse);
                }
            });
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:23,代码来源:OrderListFragmentPresenter.java

示例12: changeMyName

import rx.schedulers.Schedulers; //导入依赖的package包/类
private void changeMyName() {
    showWaitingDialog(UIUtils.getString(R.string.please_wait));
    String nickName = mEtName.getText().toString().trim();
    ApiRetrofit.getInstance().setName(nickName)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(setNameResponse -> {
                hideWaitingDialog();
                if (setNameResponse.getCode() == 200) {
                    Friend friend = DBManager.getInstance().getFriendById(UserCache.getId());
                    if (friend != null) {
                        friend.setName(nickName);
                        friend.setDisplayName(nickName);
                        DBManager.getInstance().saveOrUpdateFriend(friend);
                        BroadcastManager.getInstance(ChangeMyNameActivity.this).sendBroadcast(AppConst.CHANGE_INFO_FOR_ME);
                        BroadcastManager.getInstance(ChangeMyNameActivity.this).sendBroadcast(AppConst.CHANGE_INFO_FOR_CHANGE_NAME);
                    }
                    finish();
                }
            }, this::loadError);
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:22,代码来源:ChangeMyNameActivity.java

示例13: sendLikeNotification

import rx.schedulers.Schedulers; //导入依赖的package包/类
protected void sendLikeNotification(String likeUrl) {
    application.getWebService()
            .sendLikeNotification(likeUrl)
            .retryWhen(new RetryWithDelay(3,2000))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new BaseSubscriber<String>() {
                @Override
                public void onNext(String response) {
                    Timber.d("Got user details");
                    //     followers.setText(String.valueOf(response.size()));
                    // Toast.makeText(ChangeProfileActivity.this, "Message Sent", Toast.LENGTH_SHORT).show();
                    //  Timber.d("Message from server" + response);
                }
                @Override
                public void onError(Throwable e) {
                    Crashlytics.logException(e);
                    try {
                        Toast.makeText(PostsDetailsActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                    }catch (Exception ex){
                        ex.printStackTrace();
                    }
                }
            });
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:26,代码来源:PostsDetailsActivity.java

示例14: loadData

import rx.schedulers.Schedulers; //导入依赖的package包/类
@Override
protected void loadData() {
    RetrofitHelper.getBiliAppAPI()
            .getRecommendedBannerInfo()
            .compose(bindToLifecycle())
            .map(RecommendBannerInfo::getData)
            .flatMap(new Func1<List<RecommendBannerInfo.DataBean>, Observable<RecommendInfo>>() {
                @Override
                public Observable<RecommendInfo> call(List<RecommendBannerInfo.DataBean> dataBeans) {
                    mRecommendedBanners.addAll(dataBeans);
                    return RetrofitHelper.getBiliAppAPI().getRecommendedInfo();
                }
            })
            .compose(bindToLifecycle())
            .map(RecommendInfo::getResult)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(resultBeans -> {
                mResults.addAll(resultBeans);
                finishTask();
            }, throwable -> {
                initEmptyView();
            });
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:25,代码来源:HomeRecommendedFragment.java

示例15: dealApiReqest

import rx.schedulers.Schedulers; //导入依赖的package包/类
public void dealApiReqest(BaseApi baseApi) {
//                创建一个OkHttpClient
                OkHttpClient.Builder builder = new OkHttpClient.Builder();
                CommonSubscriber commonSubscriber = new CommonSubscriber(baseApi, mOnNextListenerSoftReference, mRxAppCompatActivitySoftReference);
                builder.addInterceptor(new CacheInterceptor()).connectTimeout(baseApi.getConnectedTime(), TimeUnit.SECONDS)
                        .writeTimeout(baseApi.getWritedOutTime(), TimeUnit.SECONDS).addNetworkInterceptor(new CacheInterceptor())
                        .cache(new Cache(CustomApplication.getInstance().getCacheDir(), 10 * 1024 * 1024));
                Retrofit retrofit = new Retrofit.Builder().client(builder.build()).baseUrl(baseApi.getBaseUrl()).addConverterFactory(ScalarsConverterFactory.create())
                        .addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
//                        .build();
//                这里原理是通过Java的动态代理创建接口的实例
                HttpService httpService = retrofit.create(HttpService.class);
                Observable observable = baseApi.getObservable(httpService);
                observable.retryWhen(new RetryWhenNetWorkException()).subscribeOn(Schedulers.io()).unsubscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread()).map(baseApi).subscribe(commonSubscriber);
        }
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:17,代码来源:CommonHttpManager.java


注:本文中的rx.schedulers.Schedulers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。