use of java8.util.Optional in project samourai-wallet-android by Samourai-Wallet.
the class WhirlpoolNotificationService method listenService.
private void listenService() {
try {
Optional<WhirlpoolWallet> whirlpoolWalletOpt = androidWhirlpoolWalletService.getWhirlpoolWallet();
if (!whirlpoolWalletOpt.isPresent()) {
// whirlpool wallet not opened yet
return;
}
// whirlpool wallet is opened
WhirlpoolWallet whirlpoolWallet = whirlpoolWalletOpt.get();
updateNotification();
Disposable stateDisposable = whirlpoolWallet.getMixingState().getObservable().observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(mixingState -> updateNotification());
Disposable repeatedChecks = Observable.fromCallable(() -> true).repeatWhen(completed -> completed.delay(3, TimeUnit.SECONDS)).subscribe(aBoolean -> {
updateNotification();
notifySuccessMixes(whirlpoolWallet.getMixingState());
}, er -> {
});
compositeDisposable.add(repeatedChecks);
compositeDisposable.add(stateDisposable);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations