コード例 #1
0
        @Override
        public void changed() {
          if (localAmountView.getAmount() != null) setExchangeDirection(false);
          else btcAmountView.setHint(null);

          if (listener != null) listener.changed();
        }
コード例 #2
0
  private void update() {
    btcAmountView.setEnabled(enabled);

    if (exchangeRate != null) {
      localAmountView.setEnabled(enabled);
      localAmountView.setCurrencySymbol(exchangeRate.currencyCode);

      if (exchangeDirection) {
        final BigInteger btcAmount = btcAmountView.getAmount();
        if (btcAmount != null) {
          localAmountView.setAmount(null, false);
          localAmountView.setHint(WalletUtils.localValue5_BTC(btcAmount, exchangeRate.rate));
          btcAmountView.setHint(null);
        }
      } else {
        final BigInteger localAmount = localAmountView.getAmount();
        if (localAmount != null) {
          btcAmountView.setAmount(null, false);
          btcAmountView.setHint(WalletUtils.btcValue_BTCtoBTQ(localAmount, exchangeRate.rate));
          localAmountView.setHint(null);
        }
      }
    } else {
      localAmountView.setEnabled(false);
      localAmountView.setHint(null);
      btcAmountView.setHint(null);
    }
  }
コード例 #3
0
  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);
    }
  }
コード例 #4
0
  private void updateAppearance() {
    if (exchangeRate != null) {
      localAmountView.setEnabled(true);

      final BigDecimal bdExchangeRate = new BigDecimal(exchangeRate);

      if (exchangeDirection) {
        final BigInteger btcAmount = btcAmountView.getAmount();
        if (btcAmount != null) {
          localAmountView.setAmount(null);
          localAmountView.setHint(
              new BigDecimal(btcAmount).multiply(bdExchangeRate).toBigInteger());
          btcAmountView.setHint(null);
        }
      } else {
        final BigInteger localAmount = localAmountView.getAmount();
        if (localAmount != null) {
          btcAmountView.setAmount(null);
          btcAmountView.setHint(
              new BigDecimal(localAmount)
                  .divide(bdExchangeRate, RoundingMode.HALF_UP)
                  .toBigInteger());
          localAmountView.setHint(null);
        }
      }

      exchangeRateView.setText(
          getString(
              R.string.amount_calculator_dialog_exchange_rate,
              exchangeCurrency,
              WalletUtils.formatValue(WalletUtils.localValue(Utils.COIN, bdExchangeRate))));
    } else {
      localAmountView.setEnabled(false);

      exchangeRateView.setText(R.string.amount_calculator_dialog_exchange_rate_not_available);
    }
  }