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


Java AndroidSchedulers类代码示例

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


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

示例1: getRelatedItems

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private Row getRelatedItems() {
	ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
	final Set<Long> related = mSelectedEvent.getMetadata().getRelated().keySet();
	mDisposables.add(((LeanbackBaseActivity) getActivity()).getApiServiceObservable()
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(
					mediaApiService -> {
						for (long id : related) {
							mDisposables.add(mediaApiService.getEvent(id)
									.observeOn(AndroidSchedulers.mainThread())
									.subscribe(event -> listRowAdapter.add(event)));
						}
						listRowAdapter.notifyArrayItemRangeChanged(0, listRowAdapter.size());
					}
			)
	);
	HeaderItem header = new HeaderItem(0, getString(R.string.related_talks));
	return new ListRow(header, listRowAdapter);
}
 
开发者ID:NiciDieNase,项目名称:chaosflix-leanback,代码行数:20,代码来源:OverlayFragment.java

示例2: onHandleParseHTML

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void onHandleParseHTML(final String url) {
    mView.showLoading(true);
    Observable.create(new ObservableOnSubscribe<ArrayList<ArticleItem>>() {
        @Override
        public void subscribe(ObservableEmitter<ArrayList<ArticleItem>> e) throws Exception {
            ArrayList<ArticleItem> list = new ArrayList<>();
            Document doc = Jsoup.connect(url).get();
            Elements ul = doc.getElementsByClass("list_line");
            for (Element u : ul) {
                Elements li = u.getElementsByTag("li");
                for (Element l : li) {
                    String text = l.getElementsByTag("a").text();
                    String href = l.getElementsByTag("a").attr("href");
                    String time = l.getElementsByTag("span").text();
                    list.add(new ArticleItem(text, href, time));
                }
            }
            e.onNext(list);
        }
    })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<ArrayList<ArticleItem>>() {
                @Override
                public void accept(@NonNull ArrayList<ArticleItem> articleItems) throws Exception {
                    mView.showList(articleItems);
                    mView.showLoading(false);
                }
            });
}
 
开发者ID:InnoFang,项目名称:PartyBuildingStudies,代码行数:32,代码来源:NewsPresenter.java

示例3: fetchRepositoryDetails

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private void fetchRepositoryDetails() {
    ApolloCall<EntryDetailQuery.Data> entryDetailQuery = application.apolloClient()
            .query(new EntryDetailQuery(repoFullName))
            .cacheControl(CacheControl.CACHE_FIRST);

    //Example call using Rx2Support
    disposables.add(Rx2Apollo.from(entryDetailQuery)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeWith(new DisposableSingleObserver<Response<EntryDetailQuery.Data>>() {
                @Override
                public void onSuccess(Response<EntryDetailQuery.Data> dataResponse) {
                    setEntryData(dataResponse.data());
                }

                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, e.getMessage(), e);
                }
            }));
}
 
开发者ID:pranayairan,项目名称:HelloApolloAndroid,代码行数:22,代码来源:GitHuntEntryDetailActivity.java

示例4: getCompanies

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private void getCompanies() {
    Disposable disposable = companiesRepository
            .getCompanies()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeWith(new DisposableObserver<List<Company>>() {
                @Override
                public void onNext(List<Company> value) {
                    view.showCompanies(value);
                }

                @Override
                public void onError(Throwable e) {

                }

                @Override
                public void onComplete() {

                }
            });
    compositeDisposable.add(disposable);
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:24,代码来源:CompaniesPresenter.java

示例5: onResume

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();

    // Load all persons and start inserting them with 1 sec. intervals.
    // All RealmObject access has to be done on the same thread `findAllAsync` was called on.
    // Warning: This example doesn't handle back pressure well.
    disposable = realm.where(Person.class).findAllAsync().asFlowable()
            .flatMap(persons -> Flowable.fromIterable(persons))
            .zipWith(Flowable.interval(1, TimeUnit.SECONDS), (person, tick) -> person)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(person -> {
                TextView personView = new TextView(AnimationActivity.this);
                personView.setText(person.getName());
                container.addView(personView);
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AnimationActivity.java

示例6: startLocationUpdates

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@SuppressWarnings("MissingPermission")
@RequiresPermission(anyOf = {
        Manifest.permission.ACCESS_COARSE_LOCATION,
        Manifest.permission.ACCESS_FINE_LOCATION
})
public void startLocationUpdates(boolean checkLocationSettings) {
    stopLocationUpdates();
    locationUpdatesDisposable = locationSettingsCheck(checkLocationSettings)
            .flatMapObservable(ignore -> locationUpdates()
                    .startWith(lastLocation()))
            .map(this::transformLocation)
            .toFlowable(BackpressureStrategy.LATEST)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(this::setLocation,
                    error -> Timber.e("Failed to get location updates", error));
}
 
开发者ID:BANKEX,项目名称:smart-asset-iot-android-demo,代码行数:17,代码来源:RxLocationManager.java

示例7: refreshBookHelps

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void refreshBookHelps(BookSort sort, int start, int limited, BookDistillate distillate) {
    Disposable refreshDispo = RemoteRepository.getInstance()
            .getBookHelps(sort.getNetName(), start, limited, distillate.getNetName())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    (beans)-> {
                        isLocalLoad = false;
                        mView.finishRefresh(beans);
                        mView.complete();
                    }
                    ,
                    (e) ->{
                        mView.complete();
                        mView.showErrorTip();
                        e(e);
                    }
            );
    addDisposable(refreshDispo);
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:22,代码来源:DiscHelpsPresenter.java

示例8: login

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
public void login(String username, String password) {
    checkViewAttached();
    getMvpView().showLoadingProgress(true);

    mSubscription.add(mDataManager.login(username, password, 1)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribeWith(new DisposableSingleObserver<Boolean>() {
                @Override
                public void onSuccess(Boolean success) {
                    if (success) {
                        loginWithCookie();
                    } else {
                        getMvpView().showError("Login Failed");
                    }
                }

                @Override
                public void onError(Throwable error) {
                    getMvpView().showError(error.getMessage());
                    getMvpView().showLoadingProgress(false);
                }
            }));
}
 
开发者ID:stuxo,项目名称:REDAndroid,代码行数:25,代码来源:LoginPresenter.java

示例9: updateWatchlist

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private Disposable updateWatchlist(List<WatchlistItem> watchlistItems) {
		return ((LeanbackBaseActivity) getActivity()).getApiServiceObservable()
				.observeOn(AndroidSchedulers.mainThread())
				.subscribe(mediaApiService -> {
					showWatchlist();
					watchListAdapter.clear();
					if(watchlistItems.size() > 0){
//						int i = Math.max(0,mRowsAdapter.indexOf(mConferencesSection));
//						mRowsAdapter.add(i,mRecomendationsSectionsRow);
//						mRowsAdapter.add(i+1,watchListAdapter);
						Observable.fromIterable(watchlistItems)
								.flatMap(watchlistItem -> mediaApiService.getEvent(watchlistItem.getEventId()))
								.observeOn(AndroidSchedulers.mainThread())
								.subscribe(event -> watchListAdapter.add(event));
					} else {
//						watchListAdapter.add("Watchlist empty");
						hideWatchlist();
					}
				});
	}
 
开发者ID:NiciDieNase,项目名称:chaosflix,代码行数:21,代码来源:ConferencesBrowseFragment.java

示例10: addCheckPointMarkers

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private void addCheckPointMarkers() {
  getCheckPointDataSource().getAllCheckPoints()
      .toObservable()
      .doOnNext(checkPoints -> allCheckPoints = (ArrayList<CheckPoint>) checkPoints)
      .flatMap(Observable::fromIterable)
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribeWith(new DisposableObserver<CheckPoint>() {
        @Override public void onNext(CheckPoint checkPoint) {
          getView().addMarkerOnMap(checkPoint);
        }

        @Override public void onError(Throwable e) {
          getView().showError(e.getLocalizedMessage());
        }

        @Override public void onComplete() {
          getView().notifyListAdapter();
        }
      });
}
 
开发者ID:Arjun-sna,项目名称:LocationAware,代码行数:22,代码来源:LocationAlarmPresenter.java

示例11: generateFlowable

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
public static Flowable<BaseUploadBean> generateFlowable(@NonNull RequestBodyWrapper uploadBeanEmitter, final String filePath){
    Flowable<BaseUploadBean> flowable = uploadBeanEmitter.getUploadProcessor()
            .publish()
            .autoConnect();

     return  flowable
             .filter(new Predicate<BaseUploadBean>() {
                 long oldProgress = 0;
                 @Override
                 public boolean test(BaseUploadBean baseUploadBean) throws Exception {
                     if(baseUploadBean instanceof UploadInfoBean){
                         long progress = ((UploadInfoBean) baseUploadBean).getData().getWrittenBytes();
                         if(progress - oldProgress > MIN_GRAD) {
                             oldProgress = progress;
                             return true;
                         }
                         return false;
                     }
                     oldProgress = 0;
                     return true;
                 }
             })
            //.throttleLast(100, TimeUnit.MILLISECONDS).mergeWith(flowable.takeLast(1))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:27,代码来源:UploadHelper.java

示例12: shareTo

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
/**
 * Share the package data.
 */
@Override
public void shareTo() {
    Disposable disposable = packagesRepository
            .getPackage(packageId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeWith(new DisposableObserver<Package>() {
                @Override
                public void onNext(Package value) {
                    view.shareTo(value);
                }

                @Override
                public void onError(Throwable e) {

                }

                @Override
                public void onComplete() {

                }
            });
    compositeDisposable.add(disposable);
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:28,代码来源:PackageDetailsPresenter.java

示例13: loadWithRetroJsoup

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
public void loadWithRetroJsoup() {
    final OkHttpClient okHttpClient = new OkHttpClient();

    final TutosAndroidFrance tutosAndroidFrance = new RetroJsoup.Builder()
            .url("http://tutos-android-france.com/")
            .client(okHttpClient)
            .build()
            .create(TutosAndroidFrance.class);

    tutosAndroidFrance.articles()
            .toList()

            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())

            .subscribe(
                    adapter::addItems,
                    Throwable::printStackTrace
            );
}
 
开发者ID:florent37,项目名称:RxRetroJsoup,代码行数:21,代码来源:MainActivity.java

示例14: refreshTag

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private void refreshTag(){
    Disposable refreshDispo = RemoteRepository.getInstance()
            .getBookTags()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    (tagBeans)-> {
                        refreshHorizonTag(tagBeans);
                        refreshGroupTag(tagBeans);
                    },
                    (e) ->{
                        LogUtils.e(e);
                    }
            );
    mDisposable.add(refreshDispo);
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:17,代码来源:BookListActivity.java

示例15: onRefresh

import io.reactivex.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void onRefresh() {
    getBinding().swipeRefreshDaily.setRefreshing(true);
    String baseUrl = "http://gank.io/api/";
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .build();

    ApiService apiService = retrofit.create(ApiService.class);
    apiService.getDailyData(mDate)
            .map(new BaseResFunc<GankDaily.Results>())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(mObserver);
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:18,代码来源:DailyListFragment.java


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