use of com.odysee.app.callable.WalletBalanceFetch in project odysee-android by OdyseeTeam.
the class MainActivity method updateWalletBalance.
public void updateWalletBalance() {
if (isSignedIn()) {
Activity a = this;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
ExecutorService executorService = Executors.newSingleThreadExecutor();
Callable<WalletBalance> c = new WalletBalanceFetch(getAuthToken());
Future<WalletBalance> f = executorService.submit(c);
try {
WalletBalance balance = f.get();
a.runOnUiThread(new Runnable() {
@Override
public void run() {
Lbry.walletBalance = balance;
for (WalletBalanceListener listener : walletBalanceListeners) {
if (listener != null) {
listener.onWalletBalanceUpdated(balance);
}
}
sendBroadcast(new Intent(ACTION_WALLET_BALANCE_UPDATED));
((TextView) findViewById(R.id.floating_balance_value)).setText(Helper.shortCurrencyFormat(Lbry.getTotalBalance()));
}
});
} catch (ExecutionException | InterruptedException e) {
e.printStackTrace();
} finally {
if (!executorService.isShutdown()) {
executorService.shutdown();
}
}
}
});
t.start();
} else {
Lbry.walletBalance = new WalletBalance();
for (WalletBalanceListener listener : walletBalanceListeners) {
if (listener != null) {
listener.onWalletBalanceUpdated(Lbry.walletBalance);
}
}
sendBroadcast(new Intent(ACTION_WALLET_BALANCE_UPDATED));
((TextView) findViewById(R.id.floating_balance_value)).setText(Helper.shortCurrencyFormat(Lbry.getTotalBalance()));
}
}
use of com.odysee.app.callable.WalletBalanceFetch in project odysee-android by OdyseeTeam.
the class FirstRunActivity method checkWalletBalanceForChannelStep.
private void checkWalletBalanceForChannelStep() {
Activity a = this;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
ExecutorService executorService = Executors.newSingleThreadExecutor();
Callable<WalletBalance> c = new WalletBalanceFetch(Lbryio.AUTH_TOKEN);
Future<WalletBalance> f = executorService.submit(c);
try {
WalletBalance wb = f.get();
a.runOnUiThread(new Runnable() {
@Override
public void run() {
if (wb.getAvailable().doubleValue() < Helper.MIN_SPEND) {
// proceed to rewards step
viewPager.setVisibility(View.VISIBLE);
progressIndicator.setVisibility(View.GONE);
proceedToRewardsStep();
} else {
emailRewardChecked();
}
}
});
} catch (Exception e) {
e.printStackTrace();
emailRewardChecked();
} finally {
if (!executorService.isShutdown()) {
executorService.shutdown();
}
}
}
});
t.start();
}
Aggregations