Search in sources :

Example 1 with MappingModelList

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;
}
Also used : FormatterOptions(org.whispersystems.signalservice.api.payments.FormatterOptions) MappingModelList(org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList) NonNull(androidx.annotation.NonNull)

Example 2 with MappingModelList

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;
}
Also used : SettingHeader(org.thoughtcrime.securesms.components.settings.SettingHeader) InProgress(org.thoughtcrime.securesms.payments.preferences.model.InProgress) MappingModelList(org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList) SeeAll(org.thoughtcrime.securesms.payments.preferences.model.SeeAll) NoRecentActivity(org.thoughtcrime.securesms.payments.preferences.model.NoRecentActivity) IntroducingPayments(org.thoughtcrime.securesms.payments.preferences.model.IntroducingPayments) NonNull(androidx.annotation.NonNull)

Example 3 with MappingModelList

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);
}
Also used : SettingHeader(org.thoughtcrime.securesms.components.settings.SettingHeader) SettingProgress(org.thoughtcrime.securesms.components.settings.SettingProgress) MappingModelList(org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList) NonNull(androidx.annotation.NonNull)

Example 4 with MappingModelList

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;
}
Also used : FormatterOptions(org.whispersystems.signalservice.api.payments.FormatterOptions) MappingModelList(org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList) NonNull(androidx.annotation.NonNull)

Example 5 with MappingModelList

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);
}
Also used : SettingHeader(org.thoughtcrime.securesms.components.settings.SettingHeader) SettingProgress(org.thoughtcrime.securesms.components.settings.SettingProgress) MappingModelList(org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)6 MappingModelList (org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList)6 SettingHeader (org.thoughtcrime.securesms.components.settings.SettingHeader)4 SettingProgress (org.thoughtcrime.securesms.components.settings.SettingProgress)2 InProgress (org.thoughtcrime.securesms.payments.preferences.model.InProgress)2 IntroducingPayments (org.thoughtcrime.securesms.payments.preferences.model.IntroducingPayments)2 NoRecentActivity (org.thoughtcrime.securesms.payments.preferences.model.NoRecentActivity)2 SeeAll (org.thoughtcrime.securesms.payments.preferences.model.SeeAll)2 FormatterOptions (org.whispersystems.signalservice.api.payments.FormatterOptions)2