use of de.schildbach.wallet.exchangerate.ExchangeRateEntry in project bitcoin-wallet by bitcoin-wallet.
the class ExchangeRatesAdapter method buildListItems.
public static List<ListItem> buildListItems(final List<ExchangeRateEntry> exchangeRates, final Coin balance, final BlockchainState blockchainState, final String defaultCurrency, final Coin rateBase) {
final List<ListItem> items = new ArrayList<>(exchangeRates.size());
for (final ExchangeRateEntry exchangeRate : exchangeRates) {
final ExchangeRate rate = exchangeRate.exchangeRate();
final String source = exchangeRate.getSource();
final String currencyCode = rate.fiat.currencyCode;
final Fiat baseRateAsFiat = rate.coinToFiat(rateBase);
final int baseRateMinDecimals = !rateBase.isLessThan(Coin.COIN) ? 2 : 4;
final Fiat balanceAsFiat = balance != null && (blockchainState == null || !blockchainState.replaying) ? rate.coinToFiat(balance) : null;
final boolean isDefault = currencyCode.equals(defaultCurrency);
items.add(new ListItem(source, currencyCode, baseRateAsFiat, baseRateMinDecimals, balanceAsFiat, isDefault));
}
return items;
}
Aggregations