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


Java DisposableSubscriber类代码示例

本文整理汇总了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");
            }
          }
      )
  );
}
 
开发者ID:apollographql,项目名称:apollo-android,代码行数:25,代码来源:GitHuntEntryDetailActivity.java

示例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;
}
 
开发者ID:MFlisar,项目名称:RxBus2,代码行数:17,代码来源:RxBusBuilder.java

示例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);
        }
    };
}
 
开发者ID:MFlisar,项目名称:RxBus2,代码行数:25,代码来源:RxBusUtil.java

示例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);
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:26,代码来源:SongsPresenter.java

示例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);
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:27,代码来源:PlaylistsPresenter.java

示例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() {

        }
    });
}
 
开发者ID:IlyaGulya,项目名称:rxlint,代码行数:19,代码来源:SubscriberTest.java

示例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();
          }
        }
      }));
}
 
开发者ID:Arjun-sna,项目名称:Android-AudioRecorder-App,代码行数:23,代码来源:AudioRecorder.java

示例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");
        }
      });
}
 
开发者ID:Arjun-sna,项目名称:Android-AudioRecorder-App,代码行数:21,代码来源:AudioRecordingDbmHandler.java

示例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();
                        }
                    }));
}
 
开发者ID:DevHugo,项目名称:commitstrip-reader,代码行数:26,代码来源:RandomStripPresenter.java

示例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);
}
 
开发者ID:kaushikgopal,项目名称:RxJava-Android-Samples,代码行数:26,代码来源:RotationPersist2Fragment.java

示例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();
                }
            };
        }
    };
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:37,代码来源:Ch9_9.java

示例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);
}
 
开发者ID:playmoweb,项目名称:store2realm,代码行数:31,代码来源:MainPresenter.java

示例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));
}
 
开发者ID:NamTranDev,项目名称:CleanArchitechture,代码行数:17,代码来源:UseCase.java

示例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);
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:28,代码来源:AlbumsPresenter.java

示例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);
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:28,代码来源:MyFavoritePresenter.java


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