Java Code Examples for io.reactivex.Observer#onNext()
The following examples show how to use
io.reactivex.Observer#onNext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoinmarketcapTickerService.java From trust-wallet-android-source with GNU General Public License v3.0 | 6 votes |
@Override public Observer<? super Response<T>> apply(Observer<? super T> observer) throws Exception { return new DisposableObserver<Response<T>>() { @Override public void onNext(Response<T> response) { observer.onNext(response.body()); observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 2
Source File: CallEnqueueObservable.java From retrocache with Apache License 2.0 | 6 votes |
@Override protected void subscribeActual(Observer<? super Response<T>> observer) { if (mCachingActive && mCachingSystem.contains(CacheUtils.urlToKey(mOriginalCall.request().url()))) { byte[] data = mCachingSystem.get(CacheUtils.urlToKey(mOriginalCall.request().url())); if (data != null) { final T convertedData = CacheUtils.bytesToResponse(mRetrofit, mResponseType, mAnnotations, data); observer.onNext(Response.success(convertedData)); observer.onComplete(); } return; } // Since Call is a one-shot type, clone it for each new mObserver. Call<T> call = mOriginalCall.clone(); CallCallback<T> callback = new CallCallback<>(call, observer, mCachingSystem, mResponseType, mAnnotations, mRetrofit, mCachingActive); observer.onSubscribe(callback); call.enqueue(callback); }
Example 3
Source File: MaybeConsumers.java From science-journal with Apache License 2.0 | 6 votes |
/** * Allows a function that takes a MaybeConsumer to pipe a single success value to the given * Observer (which may also be accepting values from other places) * * @return a {@link MaybeConsumer<T>} that pipes {@link MaybeConsumer#success(Object)} to {@link * Observer#onNext(Object)}, and {@link MaybeConsumer#fail(Exception)} to {@link * Observer#onError(Throwable)} */ public static <T> MaybeConsumer<T> fromObserver(Observer<T> o) { return new MaybeConsumer<T>() { @Override public void success(T value) { // if value is null, just report empty if (value != null) { o.onNext(value); } o.onComplete(); } @Override public void fail(Exception e) { o.onError(e); } }; }
Example 4
Source File: TrustWalletTickerService.java From trust-wallet-android-source with GNU General Public License v3.0 | 6 votes |
@Override public Observer<? super Response<T>> apply(Observer<? super T> observer) throws Exception { return new DisposableObserver<Response<T>>() { @Override public void onNext(Response<T> response) { observer.onNext(response.body()); observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 5
Source File: BlockExplorerClient.java From trust-wallet-android-source with GNU General Public License v3.0 | 6 votes |
@Override public Observer<? super retrofit2.Response<T>> apply(Observer<? super T> observer) throws Exception { return new DisposableObserver<Response<T>>() { @Override public void onNext(Response<T> response) { observer.onNext(response.body()); observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 6
Source File: CoinmarketcapTickerService.java From ETHWallet with GNU General Public License v3.0 | 6 votes |
@Override public Observer<? super Response<T>> apply(Observer<? super T> observer) throws Exception { return new DisposableObserver<Response<T>>() { @Override public void onNext(Response<T> response) { observer.onNext(response.body()); observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 7
Source File: BlockExplorerClient.java From ETHWallet with GNU General Public License v3.0 | 6 votes |
@Override public Observer<? super retrofit2.Response<T>> apply(Observer<? super T> observer) throws Exception { return new DisposableObserver<Response<T>>() { @Override public void onNext(Response<T> response) { observer.onNext(response.body()); observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 8
Source File: MercuryWalletTickerService.java From ETHWallet with GNU General Public License v3.0 | 6 votes |
@Override public Observer<? super Response<T>> apply(Observer<? super T> observer) throws Exception { return new DisposableObserver<Response<T>>() { @Override public void onNext(Response<T> response) { observer.onNext(response.body()); observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 9
Source File: BlockExplorerClient.java From Upchain-wallet with GNU Affero General Public License v3.0 | 6 votes |
@Override public Observer<? super Response<T>> apply(Observer<? super T> observer) throws Exception { return new DisposableObserver<Response<T>>() { @Override public void onNext(Response<T> response) { observer.onNext(response.body()); observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 10
Source File: EthplorerTokenService.java From trust-wallet-android-source with GNU General Public License v3.0 | 5 votes |
@Override public Observer<? super Response<EthplorerResponse>> apply(Observer<? super EthplorerResponse> observer) throws Exception { return new DisposableObserver<Response<EthplorerResponse>>() { @Override public void onNext(Response<EthplorerResponse> response) { EthplorerResponse body = response.body(); if (body != null && body.error == null) { observer.onNext(body); observer.onComplete(); } else { if (body != null) { observer.onError(new ApiErrorException(new ErrorEnvelope(body.error.code, body.error.message))); } else { observer.onError(new ApiErrorException(new ErrorEnvelope(UNKNOWN, "Service not available"))); } } } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 11
Source File: EthplorerTokenService.java From ETHWallet with GNU General Public License v3.0 | 5 votes |
@Override public Observer<? super Response<EthplorerResponse>> apply(Observer<? super EthplorerResponse> observer) throws Exception { return new DisposableObserver<Response<EthplorerResponse>>() { @Override public void onNext(Response<EthplorerResponse> response) { EthplorerResponse body = response.body(); if (body != null && body.error == null) { observer.onNext(body); observer.onComplete(); } else { if (body != null) { observer.onError(new ApiErrorException(new ErrorEnvelope(body.error.code, body.error.message))); } else { observer.onError(new ApiErrorException(new ErrorEnvelope(UNKNOWN, "Service not available"))); } } } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }
Example 12
Source File: CallExecuteObservable.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
@Override protected void subscribeActual(Observer<? super Response<T>> observer) { // Since Call is a one-shot type, clone it for each new observer. Call<T> call = originalCall.clone(); observer.onSubscribe(new CallDisposable(call)); boolean terminated = false; try { Response<T> response = call.execute(); if (!call.isCanceled()) { observer.onNext(response); } if (!call.isCanceled()) { terminated = true; observer.onComplete(); } } catch (Throwable t) { Exceptions.throwIfFatal(t); if (terminated) { RxJavaPlugins.onError(t); } else if (!call.isCanceled()) { try { observer.onError(t); } catch (Throwable inner) { Exceptions.throwIfFatal(inner); RxJavaPlugins.onError(new CompositeException(t, inner)); } } } }
Example 13
Source File: LcObservableRange.java From akarnokd-misc with Apache License 2.0 | 5 votes |
@Override protected void subscribeActual(Observer<? super Integer> downstream) { downstream.onSubscribe(this); for (int i = start; i < end; i++) { if (disposed) { return; } downstream.onNext(i); } if (disposed) { return; } downstream.onComplete(); }
Example 14
Source File: PatternLockViewCompleteObservable.java From PatternLockView with Apache License 2.0 | 5 votes |
@Override protected void subscribeActual(Observer<? super PatternLockCompleteEvent> observer) { subscribeListener(observer); if (mEmitInitialValue) { observer.onNext(new PatternLockCompleteEvent(mPatternLockView.getPattern())); } }
Example 15
Source File: RxSubscriptionUtil.java From RxBus2 with Apache License 2.0 | 5 votes |
public static <T> Observer<T> wrapObserver(Observer<T> observer, IRxBusQueue isResumedProvider) { return new Observer<T>() { @Override public void onSubscribe(Disposable d) { observer.onSubscribe(d); } @Override public void onComplete() { observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onNext(T t) { if (RxUtil.safetyQueueCheck(t, isResumedProvider)) observer.onNext(t); } }; }
Example 16
Source File: RxBusUtil.java From RxBus2 with Apache License 2.0 | 5 votes |
public static <T> Observer<T> wrapObserver(Observer<T> observer, IRxBusQueue isResumedProvider) { return new Observer<T>() { @Override public void onSubscribe(Disposable d) { observer.onSubscribe(d); } @Override public void onComplete() { observer.onComplete(); } @Override public void onError(Throwable e) { observer.onError(e); } @Override public void onNext(T t) { if (RxUtil.safetyQueueCheck(t, isResumedProvider)) observer.onNext(t); } }; }
Example 17
Source File: Helpers.java From jobson with Apache License 2.0 | 5 votes |
private static void streamInto(InputStream inputStream, Observer<byte[]> observer) throws IOException { byte[] bytes = new byte[STDIO_BUFFER_LEN_IN_BYTES]; int bufLen; while((bufLen = inputStream.read(bytes, 0, STDIO_BUFFER_LEN_IN_BYTES)) != -1) { // Copy is necessary because observers might assume the buffer is // immutable, coming from an observable. byte[] outputBytes = new byte[bufLen]; arraycopy(bytes, 0, outputBytes, 0, bufLen); observer.onNext(outputBytes); } observer.onComplete(); }
Example 18
Source File: CellExposureObservable.java From Tangram-Android with MIT License | 5 votes |
@Override protected void subscribeActual(Observer<? super ClickExposureCellOp> observer) { if (mExposureDispose == null) { mExposureDispose = new ExposureDispose(); } observer.onSubscribe(mExposureDispose); if (!mExposureDispose.isDisposed()) { observer.onNext(mRxClickExposureEvent); } }
Example 19
Source File: CallExecuteObservable.java From retrocache with Apache License 2.0 | 5 votes |
@Override protected void subscribeActual(Observer<? super Response<T>> observer) { // Since Call is a one-shot type, clone it for each new observer. Call<T> call = mOriginalCall.clone(); observer.onSubscribe(new CallDisposable(call)); boolean terminated = false; try { Response<T> response = getResponse(call); if (mCachingActive && !mCachingSystem.contains(CacheUtils.urlToKey(mOriginalCall.request().url()))) { mCachingSystem.put( CacheUtils.urlToKey(call.request().url()), CacheUtils.responseToBytes(mRetrofit, response, mResponseType, mAnnotations)); } if (!call.isCanceled()) { observer.onNext(response); } if (!call.isCanceled()) { terminated = true; observer.onComplete(); } } catch (Throwable t) { Exceptions.throwIfFatal(t); if (terminated) { RxJavaPlugins.onError(t); } else if (!call.isCanceled()) { try { observer.onError(t); } catch (Throwable inner) { Exceptions.throwIfFatal(inner); RxJavaPlugins.onError(new CompositeException(t, inner)); } } } }
Example 20
Source File: SubscriptionProxy.java From RxGroups with Apache License 2.0 | 5 votes |
DisposableObserver<? super T> disposableWrapper(final Observer<? super T> observer) { return new DisposableObserver<T>() { @Override public void onNext(@NonNull T t) { observer.onNext(t); } @Override public void onError(@NonNull Throwable e) { observer.onError(e); } @Override public void onComplete() { observer.onComplete(); } }; }