use of org.whispersystems.signalservice.api.payments.FormatterOptions in project Signal-Android by WhisperSystems.
the class ConfirmPaymentFragment method createList.
@NonNull
private MappingModelList createList(@NonNull ConfirmPaymentState state) {
MappingModelList list = new MappingModelList();
FormatterOptions options = FormatterOptions.defaults();
switch(state.getFeeStatus()) {
case STILL_LOADING:
case ERROR:
list.add(new ConfirmPaymentAdapter.LoadingItem());
break;
case NOT_SET:
case SET:
list.add(new ConfirmPaymentAdapter.LineItem(getToPayeeDescription(requireContext(), state), state.getAmount().toString(options)));
if (state.getExchange() != null) {
list.add(new ConfirmPaymentAdapter.LineItem(getString(R.string.ConfirmPayment__estimated_s, state.getExchange().getCurrency().getCurrencyCode()), FiatMoneyUtil.format(getResources(), state.getExchange(), FiatMoneyUtil.formatOptions().withDisplayTime(false))));
}
list.add(new ConfirmPaymentAdapter.LineItem(getString(R.string.ConfirmPayment__network_fee), state.getFee().toString(options)));
list.add(new ConfirmPaymentAdapter.Divider());
list.add(new ConfirmPaymentAdapter.TotalLineItem(getString(R.string.ConfirmPayment__total_amount), state.getTotal().toString(options)));
}
list.add(new ConfirmPaymentAdapter.ConfirmPaymentStatus(state.getStatus(), state.getFeeStatus(), state.getBalance()));
return list;
}
use of org.whispersystems.signalservice.api.payments.FormatterOptions in project Signal-Android by signalapp.
the class ConfirmPaymentFragment method createList.
@NonNull
private MappingModelList createList(@NonNull ConfirmPaymentState state) {
MappingModelList list = new MappingModelList();
FormatterOptions options = FormatterOptions.defaults();
switch(state.getFeeStatus()) {
case STILL_LOADING:
case ERROR:
list.add(new ConfirmPaymentAdapter.LoadingItem());
break;
case NOT_SET:
case SET:
list.add(new ConfirmPaymentAdapter.LineItem(getToPayeeDescription(requireContext(), state), state.getAmount().toString(options)));
if (state.getExchange() != null) {
list.add(new ConfirmPaymentAdapter.LineItem(getString(R.string.ConfirmPayment__estimated_s, state.getExchange().getCurrency().getCurrencyCode()), FiatMoneyUtil.format(getResources(), state.getExchange(), FiatMoneyUtil.formatOptions().withDisplayTime(false))));
}
list.add(new ConfirmPaymentAdapter.LineItem(getString(R.string.ConfirmPayment__network_fee), state.getFee().toString(options)));
list.add(new ConfirmPaymentAdapter.Divider());
list.add(new ConfirmPaymentAdapter.TotalLineItem(getString(R.string.ConfirmPayment__total_amount), state.getTotal().toString(options)));
}
list.add(new ConfirmPaymentAdapter.ConfirmPaymentStatus(state.getStatus(), state.getFeeStatus(), state.getBalance()));
return list;
}
use of org.whispersystems.signalservice.api.payments.FormatterOptions in project Signal-Android by WhisperSystems.
the class MoneyView method init.
public void init(@NonNull Context context, @Nullable AttributeSet attrs) {
FormatterOptions.Builder builder = FormatterOptions.builder(Locale.getDefault());
TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.MoneyView, 0, 0);
if (styledAttributes.getBoolean(R.styleable.MoneyView_always_show_sign, false)) {
builder.alwaysPrefixWithSign();
}
formatterOptions = builder.withoutSpaceBeforeUnit().build();
String value = styledAttributes.getString(R.styleable.MoneyView_money);
if (value != null) {
try {
setMoney(Money.parse(value));
} catch (Money.ParseException e) {
throw new AssertionError("Invalid money format", e);
}
}
styledAttributes.recycle();
}
use of org.whispersystems.signalservice.api.payments.FormatterOptions in project Signal-Android by signalapp.
the class MoneyView method init.
public void init(@NonNull Context context, @Nullable AttributeSet attrs) {
FormatterOptions.Builder builder = FormatterOptions.builder(Locale.getDefault());
TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.MoneyView, 0, 0);
if (styledAttributes.getBoolean(R.styleable.MoneyView_always_show_sign, false)) {
builder.alwaysPrefixWithSign();
}
formatterOptions = builder.withoutSpaceBeforeUnit().build();
String value = styledAttributes.getString(R.styleable.MoneyView_money);
if (value != null) {
try {
setMoney(Money.parse(value));
} catch (Money.ParseException e) {
throw new AssertionError("Invalid money format", e);
}
}
styledAttributes.recycle();
}
Aggregations