当前位置: 首页>>代码示例>>Java>>正文


Java MonetaryFormat类代码示例

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


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

示例1: setCurrencySymbol

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public void setCurrencySymbol(@Nullable final String currencyCode) {
    if (MonetaryFormat.CODE_BTC.equals(currencyCode)) {
        currencySymbolDrawable = getResources().getDrawable(R.drawable.currency_symbol_btc);
        localCurrencyCode = null;
    } else if (MonetaryFormat.CODE_MBTC.equals(currencyCode)) {
        currencySymbolDrawable = getResources().getDrawable(R.drawable.currency_symbol_mbtc);
        localCurrencyCode = null;
    } else if (MonetaryFormat.CODE_UBTC.equals(currencyCode)) {
        currencySymbolDrawable = getResources().getDrawable(R.drawable.currency_symbol_ubtc);
        localCurrencyCode = null;
    } else if (currencyCode != null) // fiat
    {
        final String currencySymbol = GenericUtils.currencySymbol(currencyCode);
        final float textSize = textView.getTextSize();
        final float smallerTextSize = textSize * (20f / 24f);
        currencySymbolDrawable = new CurrencySymbolDrawable(currencySymbol, smallerTextSize, lessSignificantColor,
                textSize * 0.37f);
        localCurrencyCode = currencyCode;
    } else {
        currencySymbolDrawable = null;
        localCurrencyCode = null;
    }

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

示例2: coinFiatSpannable

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public static SpannableString coinFiatSpannable(Context context, Coin amountCoin, Fiat amountFiat, boolean primaryIsCoin, float secondaryRelativeSize) {
    String amountCoinStr = null, coinCode = null;
    if (amountCoin != null) {
        // For Coin: respect the BTC, mBTC, uBTC settings
        MonetaryFormat formatter = getMoneyFormat(context);
        amountCoinStr = formatter.noCode().format(amountCoin).toString();
        coinCode = formatter.code();
    }

    String amountFiatStr = null, fiatCode = null;
    if (amountFiat != null) {
        amountFiatStr = amountFiat.toPlainString();
        fiatCode = amountFiat.currencyCode;
    }

    if (primaryIsCoin) {
        return coinFiatSpannable(context, amountCoinStr, coinCode, amountFiatStr, fiatCode, secondaryRelativeSize);
    } else {
        return coinFiatSpannable(context, amountFiatStr, fiatCode, amountCoinStr, coinCode, secondaryRelativeSize);
    }
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:22,代码来源:UIUtils.java

示例3: formatFiat

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public String formatFiat(Fiat fiat, MonetaryFormat format, boolean appendCurrencyCode) {
    if (fiat != null) {
        try {
            final String res = format.noCode().format(fiat).toString();
            if (appendCurrencyCode)
                return res + " " + fiat.getCurrencyCode();
            else
                return res;
        } catch (Throwable t) {
            log.warn("Exception at formatFiatWithCode: " + t.toString());
            return Res.get("shared.na") + " " + fiat.getCurrencyCode();
        }
    } else {
        return Res.get("shared.na");
    }
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:17,代码来源:BSFormatter.java

示例4: BsqFormatter

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
@Inject
private BsqFormatter() {
    super();

    final String baseCurrencyCode = BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode();
    switch (baseCurrencyCode) {
        case "BTC":
            coinFormat = new MonetaryFormat().shift(5).code(5, "BSQ").minDecimals(3);
            break;
        case "LTC":
            coinFormat = new MonetaryFormat().shift(3).code(3, "BSQ").minDecimals(5);
            break;
        case "DOGE":
            // BSQ for DOGE not used/supported
            coinFormat = new MonetaryFormat().shift(3).code(3, "???").minDecimals(5);
            break;
        case "DASH":
            // BSQ for DASH not used/supported
            coinFormat = new MonetaryFormat().shift(3).code(3, "???").minDecimals(5);
            break;
        default:
            throw new RuntimeException("baseCurrencyCode not defined. baseCurrencyCode=" + baseCurrencyCode);
    }

    amountFormat.setMinimumFractionDigits(3);
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:27,代码来源:BsqFormatter.java

示例5: onBitcoinSetup

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public void onBitcoinSetup() {
    model.setWallet(bitcoin.wallet());
    addressControl.addressProperty().bind(model.addressProperty());
    balance.textProperty().bind(EasyBind.map(model.balanceProperty(), coin -> MonetaryFormat.BTC.noCode().format(coin).toString()));
    // Don't let the user click send money when the wallet is empty.
    sendMoneyOutBtn.disableProperty().bind(model.balanceProperty().isEqualTo(Coin.ZERO));

    showBitcoinSyncMessage();
    model.syncProgressProperty().addListener(x -> {
        if (model.syncProgressProperty().get() >= 1.0) {
            readyToGoAnimation();
            if (syncItem != null) {
                syncItem.cancel();
                syncItem = null;
            }
        } else if (syncItem == null) {
            showBitcoinSyncMessage();
        }
    });
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:21,代码来源:MainController.java

示例6: getFormat

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public MonetaryFormat getFormat() {
    final int shift = getBtcShift();
    final int minPrecision = shift <= 3 ? 2 : 0;
    final int decimalRepetitions = (getBtcPrecision() - minPrecision) / 2;
    return new MonetaryFormat().shift(shift).minDecimals(minPrecision).repeatOptionalDecimals(2,
            decimalRepetitions);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:8,代码来源:Configuration.java

示例7: getMaxPrecisionFormat

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public MonetaryFormat getMaxPrecisionFormat() {
    final int shift = getBtcShift();
    if (shift == 0)
        return new MonetaryFormat().shift(0).minDecimals(2).optionalDecimals(2, 2, 2);
    else if (shift == 3)
        return new MonetaryFormat().shift(3).minDecimals(2).optionalDecimals(2, 1);
    else
        return new MonetaryFormat().shift(6).minDecimals(0).optionalDecimals(2);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:10,代码来源:Configuration.java

示例8: amountFiat

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的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: formater2

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public static MonetaryFormat formater2(Context context) {
    if (SharedPrefUtils.isBitcoinScaleBTC(context)) {
        return MonetaryFormat.BTC;
    } else if (SharedPrefUtils.isBitcoinScaleMilliBTC(context)) {
        return MonetaryFormat.MBTC;
    } else if (SharedPrefUtils.isBitcoinScaleMicroBTC(context)) {
        return MonetaryFormat.UBTC;
    }
    throw new RuntimeException("unknown format");
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:11,代码来源:UIUtils.java

示例10: toFriendlyAmountString

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的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: getMoneyFormat

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public static MonetaryFormat getMoneyFormat(Context context) {
    if (SharedPrefUtils.isBitcoinScaleBTC(context)) {
        return MonetaryFormat.BTC.postfixCode();
    } else if (SharedPrefUtils.isBitcoinScaleMilliBTC(context)) {
        return MonetaryFormat.MBTC.postfixCode();
    } else if (SharedPrefUtils.isBitcoinScaleMicroBTC(context)) {
        return MonetaryFormat.UBTC.postfixCode();
    } else {
        return MonetaryFormat.BTC.postfixCode();
    }
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:12,代码来源:UIUtils.java

示例12: getFormat

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public MonetaryFormat getFormat()
{
    final int shift = getBtcShift();
    final int minPrecision = shift <= 3 ? 2 : 0;
    final int decimalRepetitions = (getBtcPrecision() - minPrecision) / 2;
    return new MonetaryFormat().shift(shift).minDecimals(minPrecision).repeatOptionalDecimals(2, decimalRepetitions);
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:8,代码来源:Configuration.java

示例13: getMaxPrecisionFormat

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public MonetaryFormat getMaxPrecisionFormat()
{
    final int shift = getBtcShift();
    if (shift == 0)
        return new MonetaryFormat().shift(0).minDecimals(2).optionalDecimals(2, 2, 2);
    else if (shift == 3)
        return new MonetaryFormat().shift(3).minDecimals(2).optionalDecimals(2, 1);
    else
        return new MonetaryFormat().shift(6).minDecimals(0).optionalDecimals(2);
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:11,代码来源:Configuration.java

示例14: setCurrencySymbol

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public void setCurrencySymbol(@Nullable final String currencyCode)
{
    if (MonetaryFormat.CODE_BTC.equals(currencyCode))
    {
        currencySymbolDrawable = getResources().getDrawable(R.drawable.currency_symbol_btc);
        localCurrencyCode = null;
    }
    else if (MonetaryFormat.CODE_MBTC.equals(currencyCode))
    {
        currencySymbolDrawable = getResources().getDrawable(R.drawable.currency_symbol_mbtc);
        localCurrencyCode = null;
    }
    else if (MonetaryFormat.CODE_UBTC.equals(currencyCode))
    {
        currencySymbolDrawable = getResources().getDrawable(R.drawable.currency_symbol_ubtc);
        localCurrencyCode = null;
    }
    else if (currencyCode != null) // fiat
    {
        final String currencySymbol = GenericUtils.currencySymbol(currencyCode);
        final float textSize = textView.getTextSize();
        final float smallerTextSize = textSize * (20f / 24f);
        currencySymbolDrawable = new CurrencySymbolDrawable(currencySymbol, smallerTextSize, lessSignificantColor, textSize * 0.37f);
        localCurrencyCode = currencyCode;
    }
    else
    {
        currencySymbolDrawable = null;
        localCurrencyCode = null;
    }

    updateAppearance();
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:34,代码来源:CurrencyAmountView.java

示例15: formatVolume

import org.bitcoinj.utils.MonetaryFormat; //导入依赖的package包/类
public String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) {
    if (volume != null) {
        Monetary monetary = volume.getMonetary();
        if (monetary instanceof Fiat)
            return formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode);
        else
            return formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode);
    } else {
        return "";
    }
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:12,代码来源:BSFormatter.java


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