本文整理汇总了Java中io.reactivex.subscribers.DisposableSubscriber类的典型用法代码示例。如果您正苦于以下问题:Java DisposableSubscriber类的具体用法?Java DisposableSubscriber怎么用?Java DisposableSubscriber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DisposableSubscriber类属于io.reactivex.subscribers包,在下文中一共展示了DisposableSubscriber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeRepoCommentAdded
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
private void subscribeRepoCommentAdded() {
ApolloSubscriptionCall<RepoCommentAddedSubscription.Data> subscriptionCall = application.apolloClient()
.subscribe(new RepoCommentAddedSubscription(repoFullName));
disposables.add(Rx2Apollo.from(subscriptionCall)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(
new DisposableSubscriber<Response<RepoCommentAddedSubscription.Data>>() {
@Override public void onNext(Response<RepoCommentAddedSubscription.Data> response) {
commentsListViewAdapter.addItem(response.data().commentAdded().content());
}
@Override public void onError(Throwable e) {
Log.e(TAG, e.getMessage(), e);
}
@Override public void onComplete() {
Log.d(TAG, "Subscription exhausted");
}
}
)
);
}
示例2: subscribe
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
public <R> Disposable subscribe(DisposableSubscriber<R> subscriber, FlowableTransformer<T, R> transformer)
{
Flowable flowable = build(false);
if (transformer != null)
flowable = flowable.compose(transformer);
Subscriber<R> actualSubscriber = subscriber;
if (mQueuer != null && mQueueSubscriptionSafetyCheckEnabled)
actualSubscriber = RxBusUtil.wrapSubscriber(subscriber, mQueuer);
flowable = applySchedular(flowable);
Disposable disposable = (DisposableSubscriber)flowable.subscribeWith(actualSubscriber);
if (mBoundObject != null)
RxDisposableManager.addDisposable(mBoundObject, disposable);
return disposable;
}
示例3: wrapSubscriber
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
protected static <T> DisposableSubscriber<T> wrapSubscriber(DisposableSubscriber<T> subscriber, IRxBusQueue isResumedProvider)
{
return new DisposableSubscriber<T>()
{
@Override
public void onComplete()
{
subscriber.onComplete();
}
@Override
public void onError(Throwable e)
{
subscriber.onError(e);
}
@Override
public void onNext(T t)
{
if (RxUtil.safetyQueueCheck(t, isResumedProvider))
subscriber.onNext(t);
}
};
}
示例4: loadSongs
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
@Override
public void loadSongs() {
mDisposables.clear();
Disposable disposable = mRepository.getAllSongs().subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSubscriber<List<Song>>() {
@Override
public void onError(Throwable throwable) {
LogUtils.e(TAG, "onError :" + throwable.toString());
}
@Override
public void onComplete() {
LogUtils.i(TAG, "onCompleted");
}
@Override
public void onNext(List<Song> songs) {
onLoadSongsFinished(songs);
}
});
mDisposables.add(disposable);
}
示例5: loadPlaylists
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
@Override
public void loadPlaylists() {
LogUtils.i(TAG, "loadPlaylists");
mDisposables.clear();
Disposable disposable = mRepository.getAllPlaylists().subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSubscriber<List<Playlist>>() {
@Override
public void onError(Throwable throwable) {
LogUtils.e(TAG, "loadPlaylists Error :" + throwable.toString());
}
@Override
public void onComplete() {
}
@Override
public void onNext(List<Playlist> playlists) {
onLoadPlaylistsFinished(playlists);
}
});
mDisposables.add(disposable);
}
示例6: rx2FlowableWithSubscriber
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
public void rx2FlowableWithSubscriber() {
io.reactivex.Flowable.just("test").subscribeWith(new DisposableSubscriber<String>() {
@Override
public void onNext(String s) {
}
@Override
public void onError(Throwable t) {
}
@Override
public void onComplete() {
}
});
}
示例7: startRecordThread
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
private void startRecordThread() {
audioDataFlowable.subscribeOn(Schedulers.io()).subscribe(recordDataPublishProcessor);
compositeDisposable.add(recordDataPublishProcessor.onBackpressureBuffer()
.observeOn(Schedulers.io())
.subscribeWith(new DisposableSubscriber<byte[]>() {
@Override public void onNext(byte[] bytes) {
audioSaveHelper.onDataReady(recordBuffer);
}
@Override public void onError(Throwable t) {
}
@Override public void onComplete() {
audioSaveHelper.onRecordingStopped(currentRecordTime);
synchronized (recorderStateMonitor) {
recorderState = RECORDER_STATE_IDLE;
recorderStateMonitor.notifyAll();
}
}
}));
}
示例8: startDbmThread
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
@Override public void startDbmThread() {
disposableSubscriber = audioRecorder.getAudioDataFlowable()
.onBackpressureLatest()
.observeOn(Schedulers.newThread())
.subscribeWith(new DisposableSubscriber<byte[]>() {
@Override public void onNext(byte[] moreData) {
if (moreData != null && moreData.length > 0) {
onDataReceived(moreData);
}
}
@Override public void onError(Throwable t) {
Log.i("Visual Error ", t.getMessage() + " ");
}
@Override public void onComplete() {
Log.i("Visualise ", "complete");
}
});
}
示例9: fetchStrip
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
@Override
public void fetchStrip(Integer numberOfStripPerPage, int page) {
mSubscriptions.add(
fetchRandomStrip(numberOfStripPerPage)
.subscribeWith(new DisposableSubscriber<StripDto>() {
@Override public void onNext(StripDto strip) {
mAlreadyDisplayedId.add(strip.getId());
mListCurrentDisplayStrip.add(strip);
}
@Override public void onError(Throwable e) {}
@Override public void onComplete() {
List<StripWithImageDto> displayStrips = new ArrayList<>();
for (int i = 0; i < mListCurrentDisplayStrip.size(); i++) {
displayStrips.add(
convertStripDtoToStripWithImageDto(mListCurrentDisplayStrip.get(i)));
}
mListStripView.addMoreStrips(displayStrips);
mListCurrentDisplayStrip.clear();
}
}));
}
示例10: setStream
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
@Override
public void setStream(Flowable<Integer> intStream) {
DisposableSubscriber<Integer> d =
new DisposableSubscriber<Integer>() {
@Override
public void onNext(Integer integer) {
_log(String.format("Worker frag spits out - %d", integer));
}
@Override
public void onError(Throwable e) {
Timber.e(e, "Error in worker demo frag observable");
_log("Dang! something went wrong.");
}
@Override
public void onComplete() {
_log("Observable is complete");
}
};
intStream.doOnSubscribe(subscription -> _log("Subscribing to intsObservable")).subscribe(d);
_disposables.add(d);
}
示例11: doOnEmpty
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
public static <T> FlowableOperator<T, T> doOnEmpty(Action
action) {
return new FlowableOperator<T, T>() {
@Override
public Subscriber<? super T> apply(Subscriber<? super
T> subscriber) throws Exception {
return new DisposableSubscriber<T>() {
boolean isEmpty = true;
@Override
public void onNext(T value) {
isEmpty = false;
subscriber.onNext(value);
}
@Override
public void onError(Throwable t) {
subscriber.onError(t);
}
@Override
public void onComplete() {
if (isEmpty) {
try {
action.run();
} catch (Exception e) {
onError(e);
return;
}
}
subscriber.onComplete();
}
};
}
};
}
示例12: loadPosts
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
public void loadPosts(boolean filterAndSortPosts) {
SortingMode sortingMode = null;
Filter filter = null;
if(filterAndSortPosts){
sortingMode = new SortingMode("userId", SortType.ASCENDING);
filter = new Filter("userId", 5);
}
Disposable d = postService.getAll(filter, sortingMode)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSubscriber<Optional<List<Post>>>(){
@Override
public void onNext(Optional<List<Post>> items) {
mainView.updatePosts(items.get());
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onComplete() {
}
});
disposable.add(d);
}
示例13: execute
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
/**
* Executes the current use case.
*
* @param subscriber {@link DisposableSubscriber} which will be listening to the observable build
* by {@link #buildUseCaseFlowable(Params)} ()} method.
* @param params Parameters (Optional) used to build/execute this use case.
*/
public void execute(DisposableSubscriber<T> subscriber, Params params) {
Preconditions.checkNotNull(subscriber);
if (subscriber.isDisposed())
subscriber.dispose();
final Flowable<T> observable = this.buildUseCaseFlowable(params)
.subscribeOn(schedulerProvider.io())
.observeOn(schedulerProvider.ui());
addDisposable(observable.subscribeWith(subscriber));
}
示例14: loadAlbums
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
@Override
public void loadAlbums() {
LogUtils.i(TAG, "loadAlbums");
mDisposables.clear();
Disposable disposable = mRepository.getAllAlbums().subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSubscriber<List<Album>>() {
@Override
public void onError(Throwable throwable) {
LogUtils.e(TAG, "loadAlbums onError : " + throwable.toString());
}
@Override
public void onComplete() {
}
@Override
public void onNext(List<Album> albumList) {
onLoadSongsFinished(albumList);
}
});
mDisposables.add(disposable);
}
示例15: loadMyFavoriteSongs
import io.reactivex.subscribers.DisposableSubscriber; //导入依赖的package包/类
@Override
public void loadMyFavoriteSongs() {
if (mDisposables != null) {
mDisposables.clear();
}
Disposable disposable = mRepository.getMyFavoriteSongs().subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSubscriber<List<Song>>() {
@Override
public void onError(Throwable e) {
LogUtils.e(TAG, "loadMyFavoriteSongs error : " + e.toString());
}
@Override
public void onComplete() {
}
@Override
public void onNext(List<Song> songs) {
onLoadFinished(songs);
}
});
mDisposables.add(disposable);
}