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


Java Fiat.valueOf方法代码示例

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


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

示例1: getExchangeRate

import org.bitcoinj.utils.Fiat; //导入方法依赖的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

示例2: coinConvert

import org.bitcoinj.utils.Fiat; //导入方法依赖的package包/类
private Coin coinConvert() {
    if(isBitcoinPrimary) {
        return Coin.valueOf(amountBTC);
    } else {
        //convert first
        String  currency = SharedPrefUtils.getCurrency(getActivity());
        Fiat fiat = Fiat.valueOf(currency, amountFiat);
        if(exchangeRate.fiat.currencyCode.equals(fiat.currencyCode)) {
            //exchange rate is set from the service, which may not have stared yet
            Coin retVal = exchangeRate.fiatToCoin(fiat);
            amountBTC = retVal.value;
            return retVal;
        }
        return Coin.ZERO;
    }
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:17,代码来源:KeyboardFragment.java

示例3: getCachedExchangeRate

import org.bitcoinj.utils.Fiat; //导入方法依赖的package包/类
public ExchangeRate getCachedExchangeRate() {
    if (prefs.contains(PREFS_KEY_CACHED_EXCHANGE_CURRENCY) && prefs.contains(PREFS_KEY_CACHED_EXCHANGE_RATE_COIN)
            && prefs.contains(PREFS_KEY_CACHED_EXCHANGE_RATE_FIAT)) {
        final String cachedExchangeCurrency = prefs.getString(PREFS_KEY_CACHED_EXCHANGE_CURRENCY, null);
        final Coin cachedExchangeRateCoin = Coin.valueOf(prefs.getLong(PREFS_KEY_CACHED_EXCHANGE_RATE_COIN, 0));
        final Fiat cachedExchangeRateFiat = Fiat.valueOf(cachedExchangeCurrency,
                prefs.getLong(PREFS_KEY_CACHED_EXCHANGE_RATE_FIAT, 0));
        return new ExchangeRate(new org.bitcoinj.utils.ExchangeRate(cachedExchangeRateCoin, cachedExchangeRateFiat),
                null);
    } else {
        return null;
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:14,代码来源:Configuration.java

示例4: getExchangeRate

import org.bitcoinj.utils.Fiat; //导入方法依赖的package包/类
public static ExchangeRate getExchangeRate(final Cursor cursor) {
    final String currencyCode = cursor
            .getString(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_CURRENCY_CODE));
    final Coin rateCoin = Coin
            .valueOf(cursor.getLong(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_RATE_COIN)));
    final Fiat rateFiat = Fiat.valueOf(currencyCode,
            cursor.getLong(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_RATE_FIAT)));
    final String source = cursor.getString(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_SOURCE));

    return new ExchangeRate(new org.bitcoinj.utils.ExchangeRate(rateCoin, rateFiat), source);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:12,代码来源:ExchangeRatesProvider.java

示例5: valueOf

import org.bitcoinj.utils.Fiat; //导入方法依赖的package包/类
public static Price valueOf(String currencyCode, long value) {
    if (CurrencyUtil.isFiatCurrency(currencyCode)) {
        return new Price(Fiat.valueOf(currencyCode, value));
    } else {
        return new Price(Altcoin.valueOf(currencyCode, value));
    }
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:8,代码来源:Price.java

示例6: parseToFiat

import org.bitcoinj.utils.Fiat; //导入方法依赖的package包/类
protected Fiat parseToFiat(String input, String currencyCode) {
    if (input != null && input.length() > 0) {
        try {
            return Fiat.parseFiat(currencyCode, cleanDoubleInput(input));
        } catch (Exception e) {
            log.warn("Exception at parseToFiat: " + e.toString());
            return Fiat.valueOf(currencyCode, 0);
        }

    } else {
        return Fiat.valueOf(currencyCode, 0);
    }
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:14,代码来源:BSFormatter.java

示例7: parseToFiatWithPrecision

import org.bitcoinj.utils.Fiat; //导入方法依赖的package包/类
/**
 * Converts to a fiat with max. 2 decimal places. Last place gets rounded.
 * 0.234 -> 0.23
 * 0.235 -> 0.24
 *
 * @param input
 * @return
 */

public Fiat parseToFiatWithPrecision(String input, String currencyCode) {
    if (input != null && input.length() > 0) {
        try {
            return parseToFiat(new BigDecimal(cleanDoubleInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString(),
                    currencyCode);
        } catch (Throwable t) {
            log.warn("Exception at parseToFiatWithPrecision: " + t.toString());
            return Fiat.valueOf(currencyCode, 0);
        }

    }
    return Fiat.valueOf(currencyCode, 0);
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:23,代码来源:BSFormatter.java

示例8: parseFiatInexact

import org.bitcoinj.utils.Fiat; //导入方法依赖的package包/类
private static Fiat parseFiatInexact(final String currencyCode, final String str) {
    final long val = new BigDecimal(str).movePointRight(Fiat.SMALLEST_UNIT_EXPONENT).longValue();
    return Fiat.valueOf(currencyCode, val);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:5,代码来源:ExchangeRatesProvider.java


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