Search in sources :

Example 6 with MappingModelList

use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModelList in project Signal-Android by signalapp.

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)

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