コード例 #1
0
ファイル: PopActivity.java プロジェクト: badzso/wallet
 private TransactionSummary findFirstMatchingTransaction(
     PopRequest popRequest, List<TransactionSummary> transactions) {
   MetadataStorage metadataStorage = _mbwManager.getMetadataStorage();
   for (TransactionSummary transactionSummary : transactions) {
     if (PopUtils.matches(popRequest, metadataStorage, transactionSummary)) {
       return transactionSummary;
     }
   }
   return null;
 }
コード例 #2
0
ファイル: PopActivity.java プロジェクト: badzso/wallet
  private void updateUi(TransactionSummary transactionSummary) {
    MetadataStorage metadataStorage = _mbwManager.getMetadataStorage();

    // Set Date
    Date date = new Date(transactionSummary.time * 1000L);
    DateFormat dateFormat = new AdaptiveDateFormat(getApplicationContext());
    setText(R.id.pop_transaction_date, dateFormat.format(date));

    // Set amount
    long amountSatoshis = getPaymentAmountSatoshis(transactionSummary);
    String value = _mbwManager.getBtcValueString(amountSatoshis);
    String fiatValue =
        _mbwManager.getCurrencySwitcher().getFormattedFiatValue(amountSatoshis, true);
    String fiatAppendment = "";
    if (!Strings.isNullOrEmpty(fiatValue)) {
      fiatAppendment = " (" + fiatValue + ")";
    }
    setText(R.id.pop_transaction_amount, value + fiatAppendment);

    // Set label
    String label = metadataStorage.getLabelByTransaction(transactionSummary.txid);
    setText(R.id.pop_transaction_label, label);

    URL url = getUrl(popRequest.getP());
    if (url == null) {
      Toast.makeText(this, "Invalid URL:" + popRequest.getP(), Toast.LENGTH_LONG).show();
      finish();
      return;
    }

    TextView textView = (TextView) findViewById(R.id.pop_recipient_host);
    textView.setText(url.getHost());
    String protocol = url.getProtocol();
    if ("https".equals(protocol)) {
      textView.setCompoundDrawablesWithIntrinsicBounds(
          R.drawable.holo_dark_ic_action_secure, 0, 0, 0);
    } else if ("http".equals(protocol)) {
      textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    } else {
      Toast.makeText(this, "Unsupported protocol:" + url.getProtocol(), Toast.LENGTH_LONG).show();
      finish();
    }
  }