本文整理汇总了Java中org.bitcoinj.core.Monetary类的典型用法代码示例。如果您正苦于以下问题:Java Monetary类的具体用法?Java Monetary怎么用?Java Monetary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Monetary类属于org.bitcoinj.core包,在下文中一共展示了Monetary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidAmount
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
private boolean isValidAmount(final boolean zeroIsValid) {
final String str = textView.getText().toString().trim();
try {
if (!str.isEmpty()) {
final Monetary amount;
if (localCurrencyCode == null) {
amount = inputFormat.parse(str);
if (((Coin) amount).isGreaterThan(Constants.NETWORK_PARAMETERS.getMaxMoney()))
return false;
} else {
amount = inputFormat.parseFiat(localCurrencyCode, str);
}
// exactly zero
return zeroIsValid || amount.signum() > 0;
}
} catch (final Exception x) {
}
return false;
}
示例2: isValidAmount
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
private boolean isValidAmount(final boolean zeroIsValid)
{
final String str = textView.getText().toString().trim();
try
{
if (!str.isEmpty())
{
final Monetary amount;
if (localCurrencyCode == null)
amount = inputFormat.parse(str);
else
amount = inputFormat.parseFiat(localCurrencyCode, str);
// exactly zero
return zeroIsValid || amount.signum() > 0;
}
}
catch (final Exception x)
{
}
return false;
}
示例3: getAmount
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
@Nullable
public Monetary getAmount() {
if (!isValidAmount(false))
return null;
final String amountStr = textView.getText().toString().trim();
if (localCurrencyCode == null)
return inputFormat.parse(amountStr);
else
return inputFormat.parseFiat(localCurrencyCode, amountStr);
}
示例4: setAmount
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
public void setAmount(@Nullable final Monetary amount, final boolean fireListener) {
if (!fireListener)
textViewListener.setFire(false);
if (amount != null)
textView.setText(new MonetarySpannable(inputFormat, amountSigned, amount));
else
textView.setText(null);
if (!fireListener)
textViewListener.setFire(true);
}
示例5: onRestoreInstanceState
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
@Override
protected void onRestoreInstanceState(final Parcelable state) {
if (state instanceof Bundle) {
final Bundle bundle = (Bundle) state;
super.onRestoreInstanceState(bundle.getParcelable("super_state"));
textView.onRestoreInstanceState(bundle.getParcelable("child_textview"));
setAmount((Monetary) bundle.getSerializable("amount"), false);
} else {
super.onRestoreInstanceState(state);
}
}
示例6: onFocusChange
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
@Override
public void onFocusChange(final View v, final boolean hasFocus) {
if (!hasFocus) {
final Monetary amount = getAmount();
if (amount != null)
setAmount(amount, false);
}
if (listener != null && fire)
listener.focusChanged(hasFocus);
}
示例7: getAmount
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
@Nullable
public Monetary getAmount()
{
if (!isValidAmount(false))
return null;
final String amountStr = textView.getText().toString().trim();
if (localCurrencyCode == null)
return inputFormat.parse(amountStr);
else
return inputFormat.parseFiat(localCurrencyCode, amountStr);
}
示例8: setAmount
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
public void setAmount(@Nullable final Monetary amount, final boolean fireListener)
{
if (!fireListener)
textViewListener.setFire(false);
if (amount != null)
textView.setText(new MonetarySpannable(inputFormat, amountSigned, amount));
else
textView.setText(null);
if (!fireListener)
textViewListener.setFire(true);
}
示例9: onRestoreInstanceState
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
@Override
protected void onRestoreInstanceState(final Parcelable state)
{
if (state instanceof Bundle)
{
final Bundle bundle = (Bundle) state;
super.onRestoreInstanceState(bundle.getParcelable("super_state"));
textView.onRestoreInstanceState(bundle.getParcelable("child_textview"));
setAmount((Monetary) bundle.getSerializable("amount"), false);
}
else
{
super.onRestoreInstanceState(state);
}
}
示例10: onFocusChange
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
@Override
public void onFocusChange(final View v, final boolean hasFocus)
{
if (!hasFocus)
{
final Monetary amount = getAmount();
if (amount != null)
setAmount(amount, false);
}
if (listener != null && fire)
listener.focusChanged(hasFocus);
}
示例11: equals
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (o == null || o.getClass() != getClass())
return false;
final Monetary otherMonetary = ((MonetaryWrapper) o).getMonetary();
return monetary.getValue() == otherMonetary.getValue();
}
示例12: getAmountByVolume
import org.bitcoinj.core.Monetary; //导入依赖的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;
}
示例13: formatVolume
import org.bitcoinj.core.Monetary; //导入依赖的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 "";
}
}
示例14: formatPrice
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
public String formatPrice(Price price, MonetaryFormat fiatPriceFormat, boolean appendCurrencyCode) {
if (price != null) {
Monetary monetary = price.getMonetary();
if (monetary instanceof Fiat)
return formatFiat((Fiat) monetary, fiatPriceFormat, appendCurrencyCode);
else
return formatAltcoin((Altcoin) monetary, appendCurrencyCode);
} else {
return Res.get("shared.na");
}
}
示例15: formatPriceWithCode
import org.bitcoinj.core.Monetary; //导入依赖的package包/类
public String formatPriceWithCode(Price price) {
Monetary monetary = price.getMonetary();
if (monetary instanceof Fiat)
return formatFiat((Fiat) monetary, fiatPriceFormat, true);
else {
return formatAltcoinWithCode((Altcoin) monetary);
}
//return formatPrice(fiat) + " " + getCurrencyPair(fiat.getCurrencyCode());
}