io.reactivex.SingleTransformer Java Examples
The following examples show how to use
io.reactivex.SingleTransformer.
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: StatusExceptionResumeNextTransformer.java From RxGps with Apache License 2.0 | 6 votes |
public static <R extends Result> SingleTransformer<R, R> forSingle() { return upstream -> upstream.onErrorResumeNext(throwable -> { if(throwable instanceof StatusException) { StatusException statusException = (StatusException) throwable; if(statusException.getStatus().hasResolution()) { return Single.just((R) statusException.getResult()); } else { return Single.error(throwable); } } else { return Single.error(throwable); } }); }
Example #2
Source File: RxParser.java From tysq-android with GNU General Public License v3.0 | 5 votes |
/** * 不拆壳 * * @param <T> * @return */ public static <T> SingleTransformer<RespData<T>, RespData<T>> handleSingleToResult() { return new SingleTransformer<RespData<T>, RespData<T>>() { @Override public SingleSource<RespData<T>> apply(Single<RespData<T>> upstream) { return upstream .map(new TransToResult<T>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } }; }
Example #3
Source File: SingleUseCase.java From EasyMVP with Apache License 2.0 | 5 votes |
public SingleUseCase(final UseCaseExecutor useCaseExecutor, final PostExecutionThread postExecutionThread) { super(useCaseExecutor, postExecutionThread); schedulersTransformer = new SingleTransformer<R, R>() { @Override public Single<R> apply(Single<R> single) { return single.subscribeOn(useCaseExecutor.getScheduler()) .observeOn(postExecutionThread.getScheduler()); } }; }
Example #4
Source File: ConnectOperation.java From RxAndroidBle with Apache License 2.0 | 5 votes |
private SingleTransformer<BluetoothGatt, BluetoothGatt> wrapWithTimeoutWhenNotAutoconnecting() { return new SingleTransformer<BluetoothGatt, BluetoothGatt>() { @Override public Single<BluetoothGatt> apply(Single<BluetoothGatt> bluetoothGattSingle) { return autoConnect ? bluetoothGattSingle : bluetoothGattSingle .timeout(connectTimeout.timeout, connectTimeout.timeoutTimeUnit, connectTimeout.timeoutScheduler, prepareConnectionTimeoutError()); } }; }
Example #5
Source File: AbstractPresenter.java From Open-Mam with Apache License 2.0 | 5 votes |
public <R> SingleTransformer<? super R, ? extends R> compose() { return new SingleTransformer<R, R>() { @Override public SingleSource<R> apply(@NonNull Single<R> upstream) { return upstream .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doOnSubscribe(AbstractPresenter.this::call); } }; }
Example #6
Source File: AllocineApi.java From Android-Allocine-Api with Apache License 2.0 | 5 votes |
private <T> SingleTransformer<T, T> retry() { return new SingleTransformer<T, T>() { @Override public SingleSource<T> apply(Single<T> upstream) { return upstream.retryWhen(new Function<Flowable<Throwable>, Publisher<Object>>() { private final int MAX_COUNT = 3; private int count = 0; private final int DELAY_SECOND = 10; @Override public Publisher<Object> apply(Flowable<Throwable> throwableFlowable) throws Exception { return throwableFlowable.flatMap(new Function<Throwable, Publisher<?>>() { @Override public Publisher<?> apply(Throwable throwable) throws Exception { if (count++ < MAX_COUNT && throwable instanceof HttpException) { final HttpException httpException = (HttpException) throwable; if (httpException.code() == 403) { return Flowable.timer(DELAY_SECOND, TimeUnit.SECONDS); } } return Flowable.error(throwable); } }); } }); } }; }
Example #7
Source File: TokenRepository.java From alpha-wallet-android with MIT License | 5 votes |
private SingleTransformer<Token[], Token[]> attachEthereumStored(Wallet wallet) { return upstream -> Single.zip( upstream, attachCachedEth(wallet), (tokens, ethTokens) -> { List<Token> result = new ArrayList<>(); result.addAll(ethTokens); for (Token t : tokens) if (!t.isEthereum()) result.add(t); return result.toArray(new Token[0]); }); }
Example #8
Source File: TokenRepository.java From alpha-wallet-android with MIT License | 5 votes |
private SingleTransformer<Token[], Token[]> attachDefaultTokens(Wallet wallet) { return upstream -> Single.zip( upstream, ethereumNetworkRepository.getBlankOverrideTokens(wallet), (tokens, defaultTokens) -> { List<Token> result = mergeTokens(tokens, defaultTokens); return result.toArray(new Token[0]); }); }
Example #9
Source File: RxParser.java From tysq-android with GNU General Public License v3.0 | 5 votes |
/** * 拆壳 * * @param <T> * @return */ public static <T> SingleTransformer<RespData<T>, T> handleSingleDataResult() { return new SingleTransformer<RespData<T>, T>() { @Override public SingleSource<T> apply(Single<RespData<T>> upstream) { return upstream .map(new TransToData<T>()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } }; }
Example #10
Source File: RxUtil.java From APlayer with GNU General Public License v3.0 | 4 votes |
public static <T> SingleTransformer<T, T> applySingleScheduler() { return upstream -> upstream.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); }
Example #11
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef, ObjectCodec mapper) { return new SingleUnmarshaller<>(java.util.function.Function.identity(), mappedTypeRef, mapper); }
Example #12
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(Class<T> mappedType, ObjectCodec mapper) { return new SingleUnmarshaller<>(java.util.function.Function.identity(), mappedType, mapper); }
Example #13
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef) { return new SingleUnmarshaller<>(java.util.function.Function.identity(), mappedTypeRef); }
Example #14
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(Class<T> mappedType) { return new SingleUnmarshaller<>(java.util.function.Function.identity(), mappedType); }
Example #15
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef, ObjectCodec mapper) { return new SingleUnmarshaller<>(Buffer::getDelegate, mappedTypeRef, mapper); }
Example #16
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(Class<T> mappedType, ObjectCodec mapper) { return new SingleUnmarshaller<>(Buffer::getDelegate, mappedType, mapper); }
Example #17
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(TypeReference<T> mappedTypeRef) { return new SingleUnmarshaller<>(Buffer::getDelegate, mappedTypeRef); }
Example #18
Source File: SingleHelper.java From vertx-rx with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<Buffer, T> unmarshaller(Class<T> mappedType) { return new SingleUnmarshaller<>(Buffer::getDelegate, mappedType); }
Example #19
Source File: Rx.java From klingar with Apache License 2.0 | 4 votes |
public <T> SingleTransformer<T, T> singleSchedulers() { //noinspection unchecked return (SingleTransformer<T, T>) singleSchedulers; }
Example #20
Source File: RxUtil.java From APlayer with GNU General Public License v3.0 | 4 votes |
public static <T> SingleTransformer<T, T> applySingleSchedulerToIO() { return upstream -> upstream.subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()); }
Example #21
Source File: Operators.java From trust-wallet-android-source with GNU General Public License v3.0 | 4 votes |
public static SingleTransformer<Wallet, Wallet> savePassword( PasswordStore passwordStore, WalletRepositoryType walletRepository, String password) { return new SavePasswordOperator(passwordStore, walletRepository, password); }
Example #22
Source File: SingleUseCase.java From EasyMVP with Apache License 2.0 | 4 votes |
private SingleTransformer<? super R, ? extends R> getSchedulersTransformer() { return schedulersTransformer; }
Example #23
Source File: Operators.java From ETHWallet with GNU General Public License v3.0 | 4 votes |
public static SingleTransformer<Wallet, Wallet> savePassword(WalletRepository walletRepository) { return new SavePasswordOperator(walletRepository); }
Example #24
Source File: DatabaseUtils.java From mimi-reader with Apache License 2.0 | 4 votes |
public static <T> SingleTransformer<T, T> applySingleSchedulers() { return f -> f.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); }
Example #25
Source File: RxSchedulers.java From JReadHub with GNU General Public License v3.0 | 4 votes |
public static <T> SingleTransformer<T, T> singleIo2Main() { return upstream -> upstream.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); }
Example #26
Source File: Write.java From RxCentralBle with Apache License 2.0 | 4 votes |
@Override protected SingleTransformer<Peripheral, Irrelevant> postWrite() { return single -> single.flatMap(peripheral -> Single.just(Irrelevant.INSTANCE)); }
Example #27
Source File: AbstractWrite.java From RxCentralBle with Apache License 2.0 | votes |
protected abstract SingleTransformer<Peripheral, T> postWrite();