use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList 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.thoughtcrime.securesms.util.adapter.mapping.MappingModelList in project Signal-Android by WhisperSystems.
the class PaymentsHomeViewModel method createList.
@NonNull
private MappingModelList createList(@NonNull PaymentsHomeState state) {
MappingModelList list = new MappingModelList();
if (state.getPaymentsState() == PaymentsHomeState.PaymentsState.ACTIVATED) {
if (state.getTotalPayments() > 0) {
list.add(new SettingHeader.Item(R.string.PaymentsHomeFragment__recent_activity));
list.addAll(state.getPayments());
if (state.getTotalPayments() > MAX_PAYMENT_ITEMS) {
list.add(new SeeAll(PaymentType.PAYMENT));
}
}
if (!state.isRecentPaymentsLoaded()) {
list.add(new InProgress());
} else if (state.getRequests().isEmpty() && state.getPayments().isEmpty() && state.isRecentPaymentsLoaded()) {
list.add(new NoRecentActivity());
}
} else if (state.getPaymentsState() == PaymentsHomeState.PaymentsState.ACTIVATE_NOT_ALLOWED) {
Log.w(TAG, "Payments remotely disabled or not in region");
} else {
list.add(new IntroducingPayments(state.getPaymentsState()));
}
list.addAll(InfoCard.getInfoCards());
return list;
}
use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList in project Signal-Android by WhisperSystems.
the class SetCurrencyViewModel method createListState.
@NonNull
private CurrencyListState createListState(SetCurrencyState state) {
MappingModelList items = new MappingModelList();
boolean areAllCurrenciesLoaded = state.getCurrencyExchangeLoadState() == LoadState.LOADED;
items.addAll(fromCurrencies(state.getDefaultCurrencies(), state.getCurrentCurrency()));
items.add(new SettingHeader.Item(R.string.SetCurrencyFragment__all_currencies));
if (areAllCurrenciesLoaded) {
items.addAll(fromCurrencies(state.getOtherCurrencies(), state.getCurrentCurrency()));
} else {
items.add(new SettingProgress.Item());
}
return new CurrencyListState(items, findSelectedIndex(items), areAllCurrenciesLoaded);
}
use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList 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.thoughtcrime.securesms.util.adapter.mapping.MappingModelList in project Signal-Android by signalapp.
the class SetCurrencyViewModel method createListState.
@NonNull
private CurrencyListState createListState(SetCurrencyState state) {
MappingModelList items = new MappingModelList();
boolean areAllCurrenciesLoaded = state.getCurrencyExchangeLoadState() == LoadState.LOADED;
items.addAll(fromCurrencies(state.getDefaultCurrencies(), state.getCurrentCurrency()));
items.add(new SettingHeader.Item(R.string.SetCurrencyFragment__all_currencies));
if (areAllCurrenciesLoaded) {
items.addAll(fromCurrencies(state.getOtherCurrencies(), state.getCurrentCurrency()));
} else {
items.add(new SettingProgress.Item());
}
return new CurrencyListState(items, findSelectedIndex(items), areAllCurrenciesLoaded);
}
Aggregations