package xyz.stream.api.live;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import xyz.stream.api.database.entity.LiveFavorite;
import xyz.stream.api.database.entity.LiveHistory;
import xyz.stream.api.entity.LiveChannelEntity;

/* JADX INFO: loaded from: classes3.dex */
public final class e implements xyz.stream.api.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f35893a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ AtomicReference f35894b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ CountDownLatch f35895c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ g f35896d;

    public /* synthetic */ e(g gVar, AtomicReference atomicReference, CountDownLatch countDownLatch, int i10) {
        this.f35893a = i10;
        this.f35896d = gVar;
        this.f35894b = atomicReference;
        this.f35895c = countDownLatch;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        int i10 = this.f35893a;
        CountDownLatch countDownLatch = this.f35895c;
        AtomicReference atomicReference = this.f35894b;
        switch (i10) {
            case 0:
                atomicReference.set(new ArrayList());
                countDownLatch.countDown();
                break;
            default:
                atomicReference.set(new ArrayList());
                countDownLatch.countDown();
                break;
        }
    }

    public final void b(List list) {
        switch (this.f35893a) {
            case 0:
                if (list == null || list.isEmpty()) {
                    this.f35894b.set(new ArrayList());
                    this.f35895c.countDown();
                } else {
                    ArrayList arrayList = new ArrayList();
                    ArrayList arrayListC = g.c(this.f35896d.f35898a);
                    Iterator it = list.iterator();
                    while (it.hasNext()) {
                        LiveHistory liveHistory = (LiveHistory) it.next();
                        if (!t4.f.x(arrayList).p(new androidx.core.app.e(liveHistory, 1), 0)) {
                            g gVar = this.f35896d;
                            int iIntValue = liveHistory.getChannelId().intValue();
                            gVar.getClass();
                            LiveChannelEntity liveChannelEntityI = g.i(iIntValue, arrayListC);
                            if (liveChannelEntityI != null) {
                                arrayList.add(liveChannelEntityI);
                            }
                        }
                    }
                    this.f35894b.set(arrayList);
                    this.f35895c.countDown();
                }
                break;
            default:
                if (list == null || list.isEmpty()) {
                    this.f35894b.set(new ArrayList());
                    this.f35895c.countDown();
                } else {
                    ArrayList arrayList2 = new ArrayList();
                    ArrayList arrayListC2 = g.c(this.f35896d.f35898a);
                    Iterator it2 = list.iterator();
                    while (it2.hasNext()) {
                        LiveFavorite liveFavorite = (LiveFavorite) it2.next();
                        if (!t4.f.x(arrayList2).p(new androidx.core.app.e(liveFavorite, 2), 0)) {
                            g gVar2 = this.f35896d;
                            int iIntValue2 = liveFavorite.getChannelId().intValue();
                            gVar2.getClass();
                            LiveChannelEntity liveChannelEntityI2 = g.i(iIntValue2, arrayListC2);
                            if (liveChannelEntityI2 != null) {
                                arrayList2.add(liveChannelEntityI2);
                            }
                        }
                    }
                    this.f35894b.set(arrayList2);
                    this.f35895c.countDown();
                }
                break;
        }
    }

    @Override // xyz.stream.api.e
    public final /* bridge */ /* synthetic */ void onSuccess(Object obj) {
        switch (this.f35893a) {
            case 0:
                b((List) obj);
                break;
            default:
                b((List) obj);
                break;
        }
    }
}
