Java Code Examples for io.reactivex.SingleEmitter#onError()
The following examples show how to use
io.reactivex.SingleEmitter#onError() .
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: RxLocationSingleOnSubscribe.java From RxGps with Apache License 2.0 | 6 votes |
@Override public final void subscribe(SingleEmitter<T> emitter) throws Exception { final GoogleApiClient apiClient = createApiClient(new ApiClientConnectionCallbacks(emitter)); try { apiClient.connect(); } catch (Throwable ex) { emitter.onError(ex); } emitter.setCancellable(() -> { if (apiClient.isConnected()) { onUnsubscribed(apiClient); } apiClient.disconnect(); }); }
Example 2
Source File: RxValue.java From rxfirebase with Apache License 2.0 | 6 votes |
/** * @param emit * @return */ @NonNull @CheckReturnValue public static ValueEventListener listener(@NonNull final SingleEmitter<DataSnapshot> emit) { return new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (!emit.isDisposed()) { emit.onSuccess(dataSnapshot); } } @Override public void onCancelled(DatabaseError e) { if (!emit.isDisposed()) { emit.onError(e.toException()); } } }; }
Example 3
Source File: RxDatabaseReference.java From rxfirebase with Apache License 2.0 | 6 votes |
/** * @param emit * @return */ @NonNull @CheckReturnValue public static ValueEventListener listener(@NonNull final SingleEmitter<DataSnapshot> emit) { return new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (!emit.isDisposed()) { emit.onSuccess(dataSnapshot); } } @Override public void onCancelled(DatabaseError e) { if (!emit.isDisposed()) { emit.onError(e.toException()); } } }; }
Example 4
Source File: RxTask.java From ground-android with Apache License 2.0 | 5 votes |
private static <T> void onNullableSuccess(@Nullable T v, SingleEmitter<T> emitter) { if (v == null) { emitter.onError(new NullPointerException()); } else { emitter.onSuccess(v); } }
Example 5
Source File: AppDetailsPresenterImpl.java From android-permission-checker-app with Apache License 2.0 | 5 votes |
@NonNull private String createDirectory(SingleEmitter<String> e) { File appDir = new File(Environment.getExternalStorageDirectory() + "/AppPermissionsExtractedApk"); if (!appDir.exists()) { if (!appDir.mkdir()) { e.onError(new Exception("Error creating directory")); } } return appDir.getPath(); }
Example 6
Source File: GoogleSignInResultSingle.java From eternity with Apache License 2.0 | 5 votes |
@Override public void subscribe(SingleEmitter<GoogleSignInAccount> emitter) throws Exception { if (!result.isSuccess()) { emitter.onError(new GoogleSignInException(result)); return; } emitter.onSuccess(result.getSignInAccount()); }
Example 7
Source File: RxValue.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @param emitter * @param function * @return */ @NonNull @CheckReturnValue public static Transaction.Handler transaction( @NonNull final SingleEmitter<DataSnapshot> emitter, @NonNull final Function<MutableData, Transaction.Result> function) { return new Transaction.Handler() { @Override public Transaction.Result doTransaction(MutableData mutableData) { try { return function.apply(mutableData); } catch (Exception e) { throw new RuntimeException(e); } } @Override public void onComplete(@Nullable DatabaseError databaseError, boolean committed, @NonNull DataSnapshot dataSnapshot) { if (!emitter.isDisposed()) { if (null == databaseError) { emitter.onSuccess(dataSnapshot); } else { emitter.onError(databaseError.toException()); } } } }; }
Example 8
Source File: RxDatabaseReference.java From rxfirebase with Apache License 2.0 | 5 votes |
/** * @param emitter * @param function * @return */ @NonNull @CheckReturnValue public static Transaction.Handler transaction( @NonNull final SingleEmitter<DataSnapshot> emitter, @NonNull final Function<MutableData, Transaction.Result> function) { return new Transaction.Handler() { @Override public Transaction.Result doTransaction(MutableData mutableData) { try { return function.apply(mutableData); } catch (Exception e) { throw new RuntimeException(e); } } @Override public void onComplete(@Nullable DatabaseError databaseError, boolean committed, @NonNull DataSnapshot dataSnapshot) { if (!emitter.isDisposed()) { if (null == databaseError) { emitter.onSuccess(dataSnapshot); } else { emitter.onError(databaseError.toException()); } } } }; }
Example 9
Source File: SingleOnSubscribeExecuteAsBlocking.java From storio with Apache License 2.0 | 5 votes |
@Override public void subscribe(@NonNull SingleEmitter<Result> emitter) throws Exception { try { final Result value = preparedOperation.executeAsBlocking(); emitter.onSuccess(value); } catch (Exception e) { emitter.onError(e); } }
Example 10
Source File: SingleOnSubscribeExecuteAsBlockingOptional.java From storio with Apache License 2.0 | 5 votes |
@Override public void subscribe(@NonNull SingleEmitter<Optional<Result>> emitter) throws Exception { try { final Result value = preparedOperation.executeAsBlocking(); emitter.onSuccess(Optional.of(value)); } catch (Exception e) { emitter.onError(e); } }