2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.stores;
|
|
|
|
|
2021-07-13 20:23:20 +00:00
|
|
|
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;
|
2021-06-27 20:44:35 +00:00
|
|
|
import d0.z.d.m;
|
2021-07-13 20:23:20 +00:00
|
|
|
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;
|
2021-06-27 20:44:35 +00:00
|
|
|
/* compiled from: StoreOutboundPromotions.kt */
|
2021-07-13 20:23:20 +00:00
|
|
|
public final class StoreOutboundPromotions$handleConnectionOpen$2<T, R> implements b<List<? extends OutboundPromotion>, Observable<? extends List<? extends OutboundPromotion>>> {
|
2021-06-27 20:44:35 +00:00
|
|
|
public final /* synthetic */ StoreOutboundPromotions this$0;
|
|
|
|
|
|
|
|
/* compiled from: StoreOutboundPromotions.kt */
|
|
|
|
/* renamed from: com.discord.stores.StoreOutboundPromotions$handleConnectionOpen$2$1 reason: invalid class name */
|
2021-07-13 20:23:20 +00:00
|
|
|
public static final class AnonymousClass1<V> implements Callable<List<? extends OutboundPromotion>> {
|
|
|
|
public final /* synthetic */ List $activePromos;
|
2021-06-27 20:44:35 +00:00
|
|
|
public final /* synthetic */ StoreOutboundPromotions$handleConnectionOpen$2 this$0;
|
|
|
|
|
2021-07-13 20:23:20 +00:00
|
|
|
public AnonymousClass1(StoreOutboundPromotions$handleConnectionOpen$2 storeOutboundPromotions$handleConnectionOpen$2, List list) {
|
2021-06-27 20:44:35 +00:00
|
|
|
this.this$0 = storeOutboundPromotions$handleConnectionOpen$2;
|
2021-07-13 20:23:20 +00:00
|
|
|
this.$activePromos = list;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 20:23:20 +00:00
|
|
|
/* Return type fixed from 'java.util.List<com.discord.api.premium.OutboundPromotion>' to match base method */
|
|
|
|
@Override // java.util.concurrent.Callable
|
|
|
|
public final List<? extends OutboundPromotion> 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<T, R> implements b<List<? extends ModelEntitlement>, Long> {
|
|
|
|
public static final AnonymousClass2 INSTANCE = new AnonymousClass2();
|
|
|
|
|
|
|
|
public final Long call(List<ModelEntitlement> list) {
|
|
|
|
T t;
|
|
|
|
Long promotionId;
|
|
|
|
boolean z2;
|
|
|
|
m.checkNotNullExpressionValue(list, "entitlements");
|
|
|
|
Iterator<T> 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<? extends ModelEntitlement> list) {
|
|
|
|
return call((List<ModelEntitlement>) list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: StoreOutboundPromotions.kt */
|
|
|
|
/* renamed from: com.discord.stores.StoreOutboundPromotions$handleConnectionOpen$2$3 reason: invalid class name */
|
|
|
|
public static final class AnonymousClass3<T> implements Action1<Long> {
|
|
|
|
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<T, R> implements b<Long, List<? extends OutboundPromotion>> {
|
|
|
|
public final /* synthetic */ List $activePromos;
|
|
|
|
|
|
|
|
public AnonymousClass4(List list) {
|
|
|
|
this.$activePromos = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<OutboundPromotion> 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;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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] */
|
2021-07-13 20:23:20 +00:00
|
|
|
@Override // j0.k.b
|
|
|
|
public /* bridge */ /* synthetic */ Observable<? extends List<? extends OutboundPromotion>> call(List<? extends OutboundPromotion> list) {
|
|
|
|
return call((List<OutboundPromotion>) list);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 20:23:20 +00:00
|
|
|
public final Observable<? extends List<OutboundPromotion>> call(List<OutboundPromotion> 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);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|