public static String formatFiatValue(Value fiat) { return formatFiatValue(fiat, 2, 0); }
@Override public void bindView(final View view, final Context context, final Cursor cursor) { final ExchangeRate exchangeRate = ExchangeRatesProvider.getExchangeRate(cursor); final boolean isDefaultCurrency = exchangeRate.currencyCodeId.equals(defaultCurrency); view.setBackgroundResource(isDefaultCurrency ? R.color.bg_list_selected : R.color.bg_list); final TextView currencyCodeView = (TextView) view.findViewById(R.id.exchange_rate_row_currency_code); currencyCodeView.setText(exchangeRate.currencyCodeId); final TextView currencyNameView = (TextView) view.findViewById(R.id.exchange_rate_row_currency_name); String currencyName = WalletUtils.getCurrencyName(exchangeRate.currencyCodeId); if (currencyName != null) { currencyNameView.setText(currencyName); currencyNameView.setVisibility(View.VISIBLE); } else { currencyNameView.setText(null); currencyNameView.setVisibility(View.INVISIBLE); } final Amount rateAmountUnitView = (Amount) view.findViewById(R.id.exchange_rate_row_rate_unit); rateAmountUnitView.setAmount(GenericUtils.formatCoinValue(type, rateBase, true)); rateAmountUnitView.setSymbol(type.getSymbol()); final Amount rateAmountView = (Amount) view.findViewById(R.id.exchange_rate_row_rate); Value fiatAmount = exchangeRate.rate.convert(type, rateBase); rateAmountView.setAmount(GenericUtils.formatFiatValue(fiatAmount)); rateAmountView.setSymbol(fiatAmount.type.getSymbol()); } }
private void updateLocalRates() { if (localRates != null) { if (txVisualizer != null && localRates.containsKey(sourceType.getSymbol())) { txVisualizer.setExchangeRate(localRates.get(sourceType.getSymbol())); } if (tradeWithdrawAmount != null && localRates.containsKey(tradeWithdrawAmount.type.getSymbol())) { ExchangeRate rate = localRates.get(tradeWithdrawAmount.type.getSymbol()); Value fiatAmount = rate.convert(tradeWithdrawAmount); tradeWithdrawSendOutput.setAmountLocal(GenericUtils.formatFiatValue(fiatAmount)); tradeWithdrawSendOutput.setSymbolLocal(fiatAmount.type.getSymbol()); } } }
private void setFiatAmount(Value value) { amount.setAmount(GenericUtils.formatFiatValue(value)); amount.setSymbol(value.type.getSymbol()); amount.setVisibility(View.VISIBLE); }
public void setExchangeRate(ExchangeRate rate) { if (outputAmount != null) { Value fiatAmount = rate.convert(type, outputAmount.toCoin()); output.setAmountLocal(GenericUtils.formatFiatValue(fiatAmount)); output.setSymbolLocal(fiatAmount.type.getSymbol()); } if (isSending && feeAmount != null) { Value fiatAmount = rate.convert(type, feeAmount.toCoin()); fee.setAmountLocal(GenericUtils.formatFiatValue(fiatAmount)); fee.setSymbolLocal(fiatAmount.type.getSymbol()); } }
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); } }
public void updateView() { if (currentBalance != null) { String newBalanceStr = GenericUtils.formatFiatValue(currentBalance); mainAmount.setAmount(newBalanceStr); mainAmount.setSymbol(currentBalance.type.getSymbol()); } else { mainAmount.setAmount("-.--"); mainAmount.setSymbol(""); } swipeContainer.setRefreshing(wallet.isLoading()); }
@Override public void updateView() { if (isRemoving() || isDetached()) return; if (currentBalance != null) { String newBalanceStr = GenericUtils.formatCoinValue(type, currentBalance, isFullAmount ? AMOUNT_FULL_PRECISION : AMOUNT_SHORT_PRECISION, AMOUNT_SHIFT); accountBalance.setAmount(newBalanceStr); } if (currentBalance != null && exchangeRate != null && getView() != null) { try { Value fiatAmount = exchangeRate.rate.convert(type, currentBalance); accountExchangedBalance.setAmount(GenericUtils.formatFiatValue(fiatAmount)); accountExchangedBalance.setSymbol(fiatAmount.type.getSymbol()); } catch (Exception e) { // Should not happen accountExchangedBalance.setAmount(""); accountExchangedBalance.setSymbol("ERROR"); } } swipeContainer.setRefreshing(pocket.isLoading()); if (adapter != null) adapter.clearLabelCache(); }