本文整理汇总了Java中rx.android.schedulers.HandlerScheduler类的典型用法代码示例。如果您正苦于以下问题:Java HandlerScheduler类的具体用法?Java HandlerScheduler怎么用?Java HandlerScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HandlerScheduler类属于rx.android.schedulers包,在下文中一共展示了HandlerScheduler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onRunSchedulerExampleButtonClicked
import rx.android.schedulers.HandlerScheduler; //导入依赖的package包/类
void onRunSchedulerExampleButtonClicked() {
sampleObservable()
// Run on a background thread
.subscribeOn(HandlerScheduler.from(backgroundHandler))
// Be notified on the main thread
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<String>() {
@Override public void onCompleted() {
Log.d(TAG, "onCompleted()");
}
@Override public void onError(Throwable e) {
Log.e(TAG, "onError()", e);
}
@Override public void onNext(String string) {
Log.d(TAG, "onNext(" + string + ")");
}
});
}
开发者ID:zyj1609wz,项目名称:RxJava_RxAndroid,代码行数:21,代码来源:MainActivity.java
示例2: onCreate
import rx.android.schedulers.HandlerScheduler; //导入依赖的package包/类
public void onCreate(PlaybackServiceProxy proxy) {
mProxy = proxy;
//fire up thread and init handler
mHandlerThread = new HandlerThread("PlaybackServiceHandler", Process.THREAD_PRIORITY_MORE_FAVORABLE);
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
mHandlerScheduler = HandlerScheduler.from(mHandler);
mQueueChangeListener = new PlaybackQueueQueueChangeListener();
mSessionCallback = new MediaSessionCallback();
//tell everyone about ourselves
mQueue.setListener(mQueueChangeListener);
mSessionHolder.setCallback(mSessionCallback, mHandler);
proxy.setSessionToken(mSessionHolder.getSessionToken());
setupLocalRenderer();
mHandler.post(mLoadQueueRunnable);
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:22,代码来源:PlaybackService.java
示例3: start
import rx.android.schedulers.HandlerScheduler; //导入依赖的package包/类
public synchronized void start(long delay) {
running = true;
Timber.d("start(%d) lastEvent=%d", delay, lastEvent.get());
if (handlerThread == null) {
handlerThread = new HandlerThread("EventMonitor");
handlerThread.start();
scheduler = HandlerScheduler.from(new Handler(handlerThread.getLooper()));
}
//TODO check connectivity and fail fast
eventSubscription = eventsObservable
.subscribeOn(scheduler)
.subscribe(Subscribers.from(eventsObserver));
}
开发者ID:OpenSilk,项目名称:SyncthingAndroid,代码行数:14,代码来源:EventMonitor.java
示例4: onRunSchedulerExampleButtonClicked
import rx.android.schedulers.HandlerScheduler; //导入依赖的package包/类
void onRunSchedulerExampleButtonClicked() {
sampleObservable()
// Run on a background thread
.subscribeOn(HandlerScheduler.from(backgroundHandler))
// Be notified on the main thread
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<String>() {
@Override
public void onCompleted() {
Log.d(TAG, "onCompleted()");
schedulerTv.setText("onCompleted");
schedulerTv.setClickable(false);
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "onError()", e);
schedulerTv.setText("onError()");
schedulerTv.setClickable(false);
}
@Override
public void onNext(String string) {
Log.d(TAG, "onNext(" + string + ")");
schedulerTv.setText("onNext(" + string + ")");
schedulerTv.setClickable(false);
}
});
}
开发者ID:yeungeek,项目名称:Android-Gradle-Samples,代码行数:30,代码来源:DemoRxAndroidFragment.java
示例5: provideObserveOnScheduler
import rx.android.schedulers.HandlerScheduler; //导入依赖的package包/类
@Provides @ArtworkFetcherScope @Named("ObserveOnScheduler")
public Scheduler provideObserveOnScheduler() {
return HandlerScheduler.from(new Handler(service.getHandlerThread().getLooper()));
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:5,代码来源:ArtworkFetcherModule.java
示例6: applyCustomSchedulers
import rx.android.schedulers.HandlerScheduler; //导入依赖的package包/类
/**
* <p>
* Apply the subscribeOn/observeOn transformation of {custom_handler}/mainThread
* to an observable via compose()
* </p>
*
* <p>
* Only apply this to observables that are handling computation tasks in the background. Basically
* all non-IO work
* </p>
*
* @param <T> the transformation type
* @return the observable post-transform
*/
public static <T> Observable.Transformer<T, T> applyCustomSchedulers(final Handler subscribeHandler) {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(Observable<T> observable) {
return observable.subscribeOn(HandlerScheduler.from(subscribeHandler))
.observeOn(AndroidSchedulers.mainThread());
}
};
}
开发者ID:52inc,项目名称:android-52Kit,代码行数:24,代码来源:RxUtils.java
注:本文中的rx.android.schedulers.HandlerScheduler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论