當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。