package com.discord.stores; import android.content.SharedPreferences; import c.d.b.a.a; import com.discord.api.premium.OutboundPromotion; import com.discord.models.domain.ModelEntitlement; import com.discord.utilities.rx.ObservableExtensionsKt; import d0.z.d.m; import j0.k.b; import j0.l.e.j; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import rx.Observable; import rx.functions.Action1; /* compiled from: StoreOutboundPromotions.kt */ public final class StoreOutboundPromotions$handleConnectionOpen$2 implements b, Observable>> { public final /* synthetic */ StoreOutboundPromotions this$0; /* compiled from: StoreOutboundPromotions.kt */ /* renamed from: com.discord.stores.StoreOutboundPromotions$handleConnectionOpen$2$1 reason: invalid class name */ public static final class AnonymousClass1 implements Callable> { public final /* synthetic */ List $activePromos; public final /* synthetic */ StoreOutboundPromotions$handleConnectionOpen$2 this$0; public AnonymousClass1(StoreOutboundPromotions$handleConnectionOpen$2 storeOutboundPromotions$handleConnectionOpen$2, List list) { this.this$0 = storeOutboundPromotions$handleConnectionOpen$2; this.$activePromos = list; } /* Return type fixed from 'java.util.List' to match base method */ @Override // java.util.concurrent.Callable public final List call() { long j = this.this$0.this$0.getPrefs().getLong("CONSUMED_ENTITLEMENT_CODE", -1); List list = this.$activePromos; ArrayList S = a.S(list, "activePromos"); for (T t : list) { if (t.b() != j) { S.add(t); } } return S; } } /* compiled from: StoreOutboundPromotions.kt */ /* renamed from: com.discord.stores.StoreOutboundPromotions$handleConnectionOpen$2$2 reason: invalid class name */ public static final class AnonymousClass2 implements b, Long> { public static final AnonymousClass2 INSTANCE = new AnonymousClass2(); public final Long call(List list) { T t; Long promotionId; boolean z2; m.checkNotNullExpressionValue(list, "entitlements"); Iterator it = list.iterator(); while (true) { if (!it.hasNext()) { t = null; break; } t = it.next(); T t2 = t; if (!m.areEqual(t2.getConsumed(), Boolean.TRUE) || t2.getPromotionId() == null) { z2 = false; continue; } else { z2 = true; continue; } if (z2) { break; } } T t3 = t; return Long.valueOf((t3 == null || (promotionId = t3.getPromotionId()) == null) ? -1 : promotionId.longValue()); } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // j0.k.b public /* bridge */ /* synthetic */ Long call(List list) { return call((List) list); } } /* compiled from: StoreOutboundPromotions.kt */ /* renamed from: com.discord.stores.StoreOutboundPromotions$handleConnectionOpen$2$3 reason: invalid class name */ public static final class AnonymousClass3 implements Action1 { public final /* synthetic */ StoreOutboundPromotions$handleConnectionOpen$2 this$0; public AnonymousClass3(StoreOutboundPromotions$handleConnectionOpen$2 storeOutboundPromotions$handleConnectionOpen$2) { this.this$0 = storeOutboundPromotions$handleConnectionOpen$2; } public final void call(Long l) { SharedPreferences.Editor edit = this.this$0.this$0.getPrefs().edit(); m.checkExpressionValueIsNotNull(edit, "editor"); m.checkNotNullExpressionValue(l, "consumedPromoId"); edit.putLong("CONSUMED_ENTITLEMENT_CODE", l.longValue()); edit.apply(); } } /* compiled from: StoreOutboundPromotions.kt */ /* renamed from: com.discord.stores.StoreOutboundPromotions$handleConnectionOpen$2$4 reason: invalid class name */ public static final class AnonymousClass4 implements b> { public final /* synthetic */ List $activePromos; public AnonymousClass4(List list) { this.$activePromos = list; } public final List call(Long l) { List list = this.$activePromos; ArrayList S = a.S(list, "activePromos"); for (T t : list) { if (l == null || t.b() != l.longValue()) { S.add(t); } } return S; } } public StoreOutboundPromotions$handleConnectionOpen$2(StoreOutboundPromotions storeOutboundPromotions) { this.this$0 = storeOutboundPromotions; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // j0.k.b public /* bridge */ /* synthetic */ Observable> call(List list) { return call((List) list); } public final Observable> call(List list) { if (this.this$0.getPrefs().contains("CONSUMED_ENTITLEMENT_CODE")) { return Observable.C(new AnonymousClass1(this, list)); } m.checkNotNullExpressionValue(list, "activePromos"); return list.isEmpty() ^ true ? ObservableExtensionsKt.restSubscribeOn$default(StoreOutboundPromotions.access$getRestAPI$p(this.this$0).getMyEntitlements(521842831262875670L, false), false, 1, null).F(AnonymousClass2.INSTANCE).t(new AnonymousClass3(this)).F(new AnonymousClass4(list)) : new j(list); } }