Java Code Examples for io.reactivex.Completable#fromAction()
The following examples show how to use
io.reactivex.Completable#fromAction() .
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: IllegalOperationChecker.java From RxAndroidBle with Apache License 2.0 | 6 votes |
/** * This method checks whether the supplied characteristic possesses properties supporting the requested kind of operation, specified by * the supplied bitmask. * * Emits {@link BleIllegalOperationException} if there was no match between supported and necessary properties of characteristic and * check has not been suppressed * * @param characteristic a {@link BluetoothGattCharacteristic} the operation is done on * @param neededProperties properties required for the operation to be successfully completed * @return {@link Completable} deferring execution of the check till subscription */ public Completable checkAnyPropertyMatches(final BluetoothGattCharacteristic characteristic, final @BluetoothGattCharacteristicProperty int neededProperties) { return Completable.fromAction(new Action() { public void run() { final int characteristicProperties = characteristic.getProperties(); if ((characteristicProperties & neededProperties) == 0) { BleIllegalOperationException exception = resultHandler.handleMismatchData(characteristic, neededProperties); if (exception != null) { throw exception; } } } }); }
Example 2
Source File: AssetDefinitionService.java From alpha-wallet-android with MIT License | 6 votes |
private Completable checkEvents() { //check events for corresponding tokens return Completable.fromAction(() -> { for (EventDefinition ev : eventList) { try { getEvents(ev); } catch (Exception e) { //TODO: Handle event issues e.printStackTrace(); } } }); }
Example 3
Source File: RealWhorlwind.java From whorlwind with Apache License 2.0 | 6 votes |
@Override public Completable write(@NonNull final String name, @Nullable final ByteString value) { return Completable.fromAction(new Action() { @Override public void run() throws Exception { checkCanStoreSecurely(); synchronized (dataLock) { if (value == null) { storage.remove(name); return; } prepareKeyStore(); Cipher cipher = createCipher(); cipher.init(Cipher.ENCRYPT_MODE, getPublicKey()); storage.put(name, ByteString.of(cipher.doFinal(value.toByteArray()))); } } }); }
Example 4
Source File: LocalDbRepositoryImpl.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Completable setModuleEnabled(boolean enabled) { return Completable.fromAction(() -> { boolean result = context.getSharedPreferences(CONFIG_FILE, Context.MODE_PRIVATE) .edit().putBoolean(KEY_MODULE_ENABLED, enabled).commit(); if (!result) { throw new IOException("Failed writing module enabled value to local storage"); } }); }
Example 5
Source File: JdbcLocalTransaction.java From xian with Apache License 2.0 | 5 votes |
@Override protected Completable doBegin() { return Completable.fromAction(() -> { if (connection0.getAutoCommit()) { connection0.setAutoCommit(false); } }); }
Example 6
Source File: OngoingSubmissionsStore.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Completable saveLastGeneratedSubmissionId() { return Completable.fromAction(() -> { boolean result = context.getSharedPreferences( ONGOING_SUBMISSIONS_CONFIG_FILE, Context.MODE_PRIVATE) .edit().putInt(KEY_LAST_SUBMISSION_ID, lastGeneratedSubmissionId).commit(); if (!result) { throw new IOException("Failed writing last submission id to local storage"); } }); }
Example 7
Source File: DisplayCallbacksImpl.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
private Task<Void> logMessageClick(Action action) { Logging.logd("Attempting to record: " + MESSAGE_CLICK); Completable completable = Completable.fromAction(() -> metricsLoggerClient.logMessageClick(inAppMessage, action)); return logImpressionIfNeeded(completable); }
Example 8
Source File: MetadataIdsStore.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 5 votes |
Completable setMetadataIds(final SMSMetadata metadata) { return Completable.fromAction(() -> { OutputStream fos = context.openFileOutput(METADATA_FILE, Context.MODE_PRIVATE); JsonWriter writer = new JsonWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); getGson().toJson(metadata, SMSMetadata.class, writer); writer.flush(); writer.close(); } ); }
Example 9
Source File: DataSetCompleteRegistrationObjectRepository.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Completable deleteIfExist() { return Completable.fromAction(this::blockingDeleteIfExist); }
Example 10
Source File: DisplayCallbacksImpl.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
private Completable updateWasImpressed() { return Completable.fromAction(() -> wasImpressed = true); }
Example 11
Source File: MockLocalDbRepository.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Completable setGatewayNumber(String number) { return Completable.fromAction(() -> gatewayNumber = number); }
Example 12
Source File: ChecklistViewModel.java From Travel-Mate with MIT License | 4 votes |
public Completable insertItem(ChecklistItem item) { return Completable.fromAction(() -> mDataSource.insertItem(item)); }
Example 13
Source File: DataValueObjectRepository.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Completable delete() { return Completable.fromAction(this::blockingDelete); }
Example 14
Source File: WalletRepository.java From trust-wallet-android-source with GNU General Public License v3.0 | 4 votes |
@Override public Completable setDefaultWallet(Wallet wallet) { return Completable.fromAction(() -> preferenceRepositoryType.setCurrentWalletAddress(wallet.address)); }
Example 15
Source File: RealmTokenSource.java From ETHWallet with GNU General Public License v3.0 | 4 votes |
public Completable put(NetworkInfo networkInfo, Wallet wallet, TokenInfo tokenInfo) { return Completable.fromAction(() -> putInNeed(networkInfo, wallet, tokenInfo)); }
Example 16
Source File: JdbcLocalTransaction.java From xian with Apache License 2.0 | 4 votes |
@Override protected Completable doCommit() { return Completable.fromAction(() -> connection0.commit()); }
Example 17
Source File: JdbcLocalTransaction.java From xian with Apache License 2.0 | 4 votes |
@Override protected Completable doRollback() { return Completable.fromAction(() -> { connection0.rollback(); }); }
Example 18
Source File: ChecklistViewModel.java From Travel-Mate with MIT License | 4 votes |
public Completable updateName(final String name, final int id) { return Completable.fromAction(() -> mDataSource.updateName(name, id)); }
Example 19
Source File: WalletRepository.java From alpha-wallet-android with MIT License | 4 votes |
@Override public Completable setDefaultWallet(Wallet wallet) { return Completable.fromAction(() -> preferenceRepositoryType.setCurrentWalletAddress(wallet.address)); }
Example 20
Source File: LocalDbRepositoryImpl.java From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Completable updateEventSubmissionState(String eventUid, State state) { return Completable.fromAction(() -> eventStore.setState(eventUid, state)); }