• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ExchangeRate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.bitcoinj.utils.ExchangeRate的典型用法代码示例。如果您正苦于以下问题:Java ExchangeRate类的具体用法?Java ExchangeRate怎么用?Java ExchangeRate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExchangeRate类属于org.bitcoinj.utils包,在下文中一共展示了ExchangeRate类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: setExchangeRate

import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public void setExchangeRate(final ExchangeRate exchangeRate) {
    this.exchangeRate = exchangeRate;

    update();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:6,代码来源:CurrencyCalculatorLink.java


示例17: getExchangeRate

import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public ExchangeRate getExchangeRate() {
    return exchangeRate;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:4,代码来源:CurrencyCalculatorLink.java


示例18: loadExchangeRateFromStorage

import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
private ExchangeRate loadExchangeRateFromStorage() {
    return SharedPrefUtils.getExchangeRate(this, fiatCurrency);
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:4,代码来源:WalletService.java


示例19: getTradeVolume

import org.bitcoinj.utils.ExchangeRate; //导入依赖的package包/类
public Volume getTradeVolume() {
    if (getTradePrice().getMonetary() instanceof Altcoin)
        return new Volume(new AltcoinExchangeRate((Altcoin) getTradePrice().getMonetary()).coinToAltcoin(getTradeAmount()));
    else
        return new Volume(new ExchangeRate((Fiat) getTradePrice().getMonetary()).coinToFiat(getTradeAmount()));
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:7,代码来源:TradeStatistics2.java



注:本文中的org.bitcoinj.utils.ExchangeRate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Metadata类代码示例发布时间:2022-05-22
下一篇:
Java Meddle类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap