private void update() { btcAmountView.setEnabled(enabled); if (exchangeRate != null) { localAmountView.setEnabled(enabled); localAmountView.setCurrencySymbol(exchangeRate.fiat.currencyCode); if (exchangeDirection) { final Coin btcAmount = (Coin) btcAmountView.getAmount(); if (btcAmount != null) { localAmountView.setAmount(null, false); localAmountView.setHint(exchangeRate.coinToFiat(btcAmount)); btcAmountView.setHint(null); } } else { final Fiat localAmount = (Fiat) localAmountView.getAmount(); if (localAmount != null) { btcAmountView.setAmount(null, false); btcAmountView.setHint(exchangeRate.fiatToCoin(localAmount)); localAmountView.setHint(null); } } } else { localAmountView.setEnabled(false); localAmountView.setHint(null); btcAmountView.setHint(null); } }
@CheckForNull public Coin getAmount() { if (exchangeDirection) { return (Coin) btcAmountView.getAmount(); } else if (exchangeRate != null) { final Fiat localAmount = (Fiat) localAmountView.getAmount(); return localAmount != null ? exchangeRate.fiatToCoin(localAmount) : null; } else { return null; } }