本文整理汇总了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));
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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));
}
}
示例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);
}
}
示例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);
}
示例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);
}