本文整理汇总了Java中org.bitcoinj.utils.ExchangeRate类的典型用法代码示例。如果您正苦于以下问题:Java ExchangeRate类的具体用法?Java ExchangeRate怎么用?Java ExchangeRate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExchangeRate类属于org.bitcoinj.utils包,在下文中一共展示了ExchangeRate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toFriendlyFeeString
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public static SpannableString toFriendlyFeeString(Context context, Transaction tx) {
Coin fee = tx.getFee();
ExchangeRate exchangeRate = tx.getExchangeRate();
if (fee == null) {
return new SpannableString("");
}
StringBuffer friendlyFee = new StringBuffer(UIUtils.formatCoin(context, fee));
int feeLength = friendlyFee.length();
int exchangeRateLength = feeLength;
if (exchangeRate != null) {
friendlyFee.append(" ~ " + exchangeRate.coinToFiat(fee).toFriendlyString());
exchangeRateLength = friendlyFee.length();
}
SpannableString friendlySpannable = new SpannableString(friendlyFee);
friendlySpannable.setSpan(
new ForegroundColorSpan(ContextCompat.getColor(context, R.color.main_color_400)),
feeLength,
exchangeRateLength,
0);
return friendlySpannable;
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:27,代码来源:UIUtils.java示例2: getExchangeRate
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public static ExchangeRate getExchangeRate(Context context, String currencySymbol) {
String key = context.getString(R.string.pref_exchange_rate, currencySymbol);
long defaultValue = 0;
if (!preferences(context).contains(key)) {
String defaultResourceName = context.getString(R.string.pref_exchange_rate_default_key, currencySymbol);
int defaultResourceId = context.getResources()
.getIdentifier(defaultResourceName, "string", context.getPackageName());
if (defaultResourceId != 0) {
defaultValue = 10000 * Long.valueOf(context.getString(defaultResourceId));
} else {
defaultValue = 10000; // result: 1 coin = 1 amount of unknown currency
}
}
long oneCoinInFiat = getLong(context, key, defaultValue);
return new ExchangeRate(Fiat.valueOf(currencySymbol, oneCoinInFiat));
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:17,代码来源:SharedPrefUtils.java示例3: refreshAmountAndFee
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
private void refreshAmountAndFee() {
ExchangeRate exchangeRate = walletService != null ? walletService.getExchangeRate() : null;
final Coin amount = Coin.valueOf(getArguments().getLong(ARGS_KEY_AMOUNT, 0));
amountEditText.setText(UIUtils.coinFiatSpannable(getActivity(), amount, exchangeRate, true, 0.66f));
Address addressTo = null;
try {
addressTo = Address.fromBase58(params, getAddressText());
} catch (Exception e) {
// ignore, not valid address
}
final Coin fee = walletService != null ? walletService.estimateFee(addressTo, amount) : null;
if (fee != null) {
feeEditText.setText(UIUtils.coinFiatSpannable(getActivity(), fee, exchangeRate, true, 1.0f));
} else {
feeEditText.setText(R.string.unknown);
}
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:21,代码来源:SendDialogFragment.java示例4: refreshAmountAndFee
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
private void refreshAmountAndFee() {
ExchangeRate exchangeRate = null;
Address addressTo = null;
Coin fee = null;
if (walletService != null) {
exchangeRate = walletService.getExchangeRate();
try {
addressTo = Address.fromBase58(walletService.getNetworkParameters(), address);
} catch (Exception e) { /* ignore, not valid address */ }
fee = walletService.estimateFee(addressTo, amount);
}
TextView amountText = (TextView) authView.findViewById(R.id.authview_amount_content);
amountText.setText(UIUtils.coinFiatSpannable(getContext(), amount, exchangeRate, true, 0.75f));
TextView feeText = (TextView) authView.findViewById(R.id.authview_fee_content);
if (fee != null) {
feeText.setText(UIUtils.coinFiatSpannable(getContext(), fee, exchangeRate, true, 0.75f));
} else {
feeText.setText(R.string.unknown);
}
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:23,代码来源:AuthenticationDialog.java示例5: refreshAmountAndFee
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
private void refreshAmountAndFee() {
ExchangeRate exchangeRate = null;
Address addressTo = null;
Coin fee = null;
if (walletService != null) {
exchangeRate = walletService.getExchangeRate();
try {
addressTo = Address.fromBase58(walletService.getNetworkParameters(), address);
} catch (Exception e) { /* ignore, not valid address */ }
fee = walletService.estimateFee(addressTo, amount);
}
amountText.setText(UIUtils.coinFiatSpannable(getActivity(), amount, exchangeRate, true, 0.75f));
if (fee != null) {
feeText.setText(UIUtils.coinFiatSpannable(getActivity(), fee, exchangeRate, true, 0.75f));
} else {
feeText.setText(R.string.unknown);
}
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:22,代码来源:ApprovePaymentDialog.java示例6: setFiatCurrency
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
private void setFiatCurrency(String currencySymbol) {
fiatCurrency = currencySymbol;
if (exchangeRate == null || !fiatCurrency.equals(exchangeRate.fiat.getCurrencyCode())) {
ExchangeRate savedRate = loadExchangeRateFromStorage();
setExchangeRate(savedRate);
}
saveFiatCurrency();
broadcastBalanceChanged();
fetchExchangeRate();
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:11,代码来源:WalletService.java示例7: setExchangeRate
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
private void setExchangeRate(ExchangeRate exchangeRate) {
if (!fiatCurrency.equals(exchangeRate.fiat.getCurrencyCode())) {
throw new IllegalArgumentException(String.format(Locale.US,
"Exchange rate currency code (%s) does not match current currencyCode (%s)",
exchangeRate.fiat.getCurrencyCode(), fiatCurrency));
}
this.exchangeRate = exchangeRate;
Log.d(TAG, "setExchangeRate: 1 Bitcoin = " + exchangeRate.coinToFiat(Coin.COIN).toFriendlyString());
saveExchangeRate();
broadcastExchangeRateChanged();
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:13,代码来源:WalletService.java示例8: amountFiat
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
private String amountFiat(TransactionWrapper transaction) {
ExchangeRate rate = transaction.getTransaction().getExchangeRate();
if (rate == null) {
return null;
}
Fiat fiat = rate.coinToFiat(transaction.getAmount());
return MonetaryFormat.FIAT
.minDecimals(2)
.repeatOptionalDecimals(0, 0)
.code(0, fiat.currencyCode)
.postfixCode()
.format(fiat)
.toString();
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:16,代码来源:TransactionWrapperRecyclerViewAdapter.java示例9: coinFiatSpannable
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public static SpannableString coinFiatSpannable(Context context, Coin amountCoin, ExchangeRate exchangeRate, boolean primaryIsCoin, float secondaryRelativeSize) {
Fiat amountFiat = null;
if (exchangeRate != null && amountCoin != null) {
amountFiat = exchangeRate.coinToFiat(amountCoin);
}
return coinFiatSpannable(context, amountCoin, amountFiat, primaryIsCoin, secondaryRelativeSize);
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:8,代码来源:UIUtils.java示例10: toFriendlyAmountString
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public static SpannableString toFriendlyAmountString(Context context, TransactionWrapper transaction) {
StringBuffer friendlyAmount = new StringBuffer();
MonetaryFormat formatter = getMoneyFormat(context);
String btcCode = formatter.code();
String scaledAmount = formatter.noCode().format(transaction.getAmount()).toString();
friendlyAmount.append(scaledAmount).append(" ");
final int coinLength = friendlyAmount.length();
friendlyAmount.append(btcCode).append(" ");
final int codeLength = friendlyAmount.length();
ExchangeRate exchangeRate = transaction.getTransaction().getExchangeRate();
if (exchangeRate != null) {
Fiat fiat = exchangeRate.coinToFiat(transaction.getAmount());
friendlyAmount.append("~ " + fiat.toFriendlyString());
friendlyAmount.append(System.getProperty("line.separator") + "(1 BTC = "
+ exchangeRate.fiat.toFriendlyString() + " as of now)");
}
final int amountLength = friendlyAmount.length();
SpannableString friendlySpannable = new SpannableString(friendlyAmount);
friendlySpannable.setSpan(new RelativeSizeSpan(2), 0, coinLength, 0);
friendlySpannable.setSpan(
new ForegroundColorSpan(context.getResources().getColor(R.color.colorAccent)),
coinLength, codeLength, 0);
friendlySpannable.setSpan(
new ForegroundColorSpan(context.getResources().getColor(R.color.main_color_400)),
codeLength, amountLength, 0);
return friendlySpannable;
}
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:33,代码来源:UIUtils.java示例11: sendRequestExchangeRate
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
@Test
public void sendRequestExchangeRate() throws Exception {
receiveATransaction(wallet, myAddress);
SendRequest sendRequest = SendRequest.to(myAddress, Coin.COIN);
sendRequest.exchangeRate = new ExchangeRate(Fiat.parseFiat("EUR", "500"));
wallet.completeTx(sendRequest);
assertEquals(sendRequest.exchangeRate, sendRequest.tx.getExchangeRate());
}
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:9,代码来源:WalletTest.java示例12: getVolumeByAmount
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public Volume getVolumeByAmount(Coin amount) {
if (monetary instanceof Fiat)
return new Volume(new ExchangeRate((Fiat) monetary).coinToFiat(amount));
else if (monetary instanceof Altcoin)
return new Volume(new AltcoinExchangeRate((Altcoin) monetary).coinToAltcoin(amount));
else
throw new IllegalStateException("Monetary must be either of type Fiat or Altcoin");
}
开发者ID:bisq-network,项目名称:exchange,代码行数:9,代码来源:Price.java示例13: getAmountByVolume
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public Coin getAmountByVolume(Volume volume) {
Monetary monetary = volume.getMonetary();
if (monetary instanceof Fiat && this.monetary instanceof Fiat)
return new ExchangeRate((Fiat) this.monetary).fiatToCoin((Fiat) monetary);
else if (monetary instanceof Altcoin && this.monetary instanceof Altcoin)
return new AltcoinExchangeRate((Altcoin) this.monetary).altcoinToCoin((Altcoin) monetary);
else
return Coin.ZERO;
}
开发者ID:bisq-network,项目名称:exchange,代码行数:10,代码来源:Price.java示例14: getExchangeRate
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
/**
* Getter for {@link #exchangeRate}.
*/
@Nullable
public ExchangeRate getExchangeRate() {
return exchangeRate;
}
开发者ID:guodroid,项目名称:okwallet,代码行数:8,代码来源:Transaction.java示例15: setExchangeRate
import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
/**
* Setter for {@link #exchangeRate}.
*/
public void setExchangeRate(ExchangeRate exchangeRate) {
this.exchangeRate = exchangeRate;
}
开发者ID:guodroid,项目名称:okwallet,代码行数:7,代码来源:Transaction.java本文标签属性:
示例:示例图
代码:代码大全可复制
java:java面试题
ExchangeRate:ExchangeRate