private void updateBalance() { if (account != null) { lastBalance = account.getBalance(); } }
private void updateBalance() { lastBalance = sourceAccount.getBalance(); }
public List<Value> getBalances() { ImmutableList.Builder<Value> builder = ImmutableList.builder(); lock.lock(); try { for (WalletAccount account : accounts.values()) { builder.add(account.getBalance()); } return builder.build(); } finally { lock.unlock(); } }
private void updateBalance() { updateBalance(pocket.getBalance()); }
private void calculateNewBalance() { currentBalance = null; for (WalletAccount w : wallet.getAllAccounts()) { ExchangeRate rate = exchangeRates.get(w.getCoinType().getSymbol()); if (rate == null) { log.info("Missing exchange rate for {}, skipping...", w.getCoinType().getName()); continue; } if (currentBalance != null) { currentBalance = currentBalance.add(rate.rate.convert(w.getBalance())); } else { currentBalance = rate.rate.convert(w.getBalance()); } } }
@Override public void onMakeTrade(WalletAccount fromAccount, WalletAccount toAccount, Value amount) { Bundle args = new Bundle(); args.putString(Constants.ARG_ACCOUNT_ID, fromAccount.getId()); args.putString(Constants.ARG_SEND_TO_ACCOUNT_ID, toAccount.getId()); if (amount.type.equals(fromAccount.getCoinType())) { // TODO set the empty wallet flag in the fragment // Decide if emptying wallet or not Value lastBalance = fromAccount.getBalance(); if (amount.compareTo(lastBalance) == 0) { args.putSerializable(Constants.ARG_EMPTY_WALLET, true); } else { args.putSerializable(Constants.ARG_SEND_VALUE, amount); } } else if (amount.type.equals(toAccount.getCoinType())) { args.putSerializable(Constants.ARG_SEND_VALUE, amount); } else { throw new IllegalStateException("Amount does not have the expected type: " + amount.type); } replaceFragment(MakeTransactionFragment.newInstance(args), containerRes); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_balance, container, false); addHeaderAndFooterToList(inflater, container, view); ButterKnife.bind(this, view); setupSwipeContainer(); // TODO show empty message // Hide empty message if have some transaction history if (pocket.getTransactions().size() > 0) { emptyPocketMessage.setVisibility(View.GONE); } setupAdapter(inflater); accountBalance.setSymbol(type.getSymbol()); exchangeRate = ExchangeRatesProvider.getRate( application.getApplicationContext(), type.getSymbol(), config.getExchangeCurrencyCode()); // Update the amount updateBalance(pocket.getBalance()); return view; }
private void bindView(View row, WalletAccount account) { final ImageView icon = (ImageView) row.findViewById(R.id.account_icon); icon.setImageResource(Constants.COINS_ICONS.get(account.getCoinType())); final TextView rowLabel = (TextView) row.findViewById(R.id.account_description); rowLabel.setText(account.getDescriptionOrCoinName()); final Amount rowValue = (Amount) row.findViewById(R.id.account_balance); rowValue.setAmount(GenericUtils.formatFiatValue(account.getBalance(), 4, 0)); rowValue.setSymbol(account.getCoinType().getSymbol()); ExchangeRatesProvider.ExchangeRate rate = rates.get(account.getCoinType().getSymbol()); final Amount rowBalanceRateValue = (Amount) row.findViewById(R.id.account_balance_rate); if (rate != null && account.getCoinType() != null) { Value localAmount = rate.rate.convert(account.getBalance()); GenericUtils.formatCoinValue(localAmount.type, localAmount,true); rowBalanceRateValue.setAmount(GenericUtils.formatFiatValue(localAmount, 2, 0)); rowBalanceRateValue.setSymbol(localAmount.type.getSymbol()); rowBalanceRateValue.setVisibility(View.VISIBLE); } else { rowBalanceRateValue.setVisibility(View.GONE); } final Amount rowRateValue = (Amount) row.findViewById(R.id.exchange_rate_row_rate); if (rate != null && account.getCoinType() != null) { Value localAmount = rate.rate.convert(account.getCoinType().oneCoin()); GenericUtils.formatCoinValue(localAmount.type, localAmount, true); rowRateValue.setAmount(GenericUtils.formatFiatValue(localAmount, 2, 0)); rowRateValue.setSymbol(localAmount.type.getSymbol()); rowRateValue.setVisibility(View.VISIBLE); } else { rowRateValue.setVisibility(View.GONE); } }
boolean canSend = false; for (WalletAccount account : app.getAccounts(type)) { if (account.getBalance().isPositive()) { addPayWithAccountRow(typeAccounts, account, uri); canSend = true; boolean canExchange = false; for (WalletAccount account : app.getAllAccounts()) { if (!account.isType(type) && account.getBalance().isPositive()) { addPayWithAccountRow(exchangeAccounts, account, uri); canExchange = true;