package xyz.stream.api.viewmodel;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.api.entity.CreditsEntity;
import xyz.stream.api.entity.TagVideoEntity;

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

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

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

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

    public /* synthetic */ w(AtomicReference atomicReference, CountDownLatch countDownLatch, int i10) {
        this.f36014a = i10;
        this.f36015b = atomicReference;
        this.f36016c = countDownLatch;
    }

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

    public final void b(BaseEntity baseEntity) {
        int i10 = this.f36014a;
        AtomicReference atomicReference = this.f36015b;
        CountDownLatch countDownLatch = this.f36016c;
        switch (i10) {
            case 0:
                ArrayList arrayList = new ArrayList();
                if (baseEntity == null || baseEntity.getData() == null) {
                    atomicReference.set(arrayList);
                    countDownLatch.countDown();
                } else {
                    List list = (List) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), new SearchResultViewModel$1$1().getType());
                    if (list != null && !list.isEmpty()) {
                        ArrayList arrayListE = t4.f.x(list).e(new xyz.netfly.viewmodel.a(13)).E();
                        if (!arrayListE.isEmpty()) {
                            TagVideoEntity tagVideoEntity = new TagVideoEntity();
                            tagVideoEntity.setTagId(2);
                            tagVideoEntity.setVideoList(arrayListE);
                            arrayList.add(tagVideoEntity);
                        }
                        ArrayList arrayListE2 = t4.f.x(list).e(new xyz.netfly.viewmodel.a(14)).E();
                        if (!arrayListE2.isEmpty()) {
                            TagVideoEntity tagVideoEntity2 = new TagVideoEntity();
                            tagVideoEntity2.setTagId(3);
                            tagVideoEntity2.setVideoList(arrayListE2);
                            arrayList.add(tagVideoEntity2);
                        }
                    }
                    atomicReference.set(arrayList);
                    countDownLatch.countDown();
                }
                break;
            default:
                ArrayList arrayList2 = new ArrayList();
                if (baseEntity == null || baseEntity.getData() == null) {
                    atomicReference.set(arrayList2);
                    countDownLatch.countDown();
                } else {
                    List<CreditsEntity> list2 = (List) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), new SearchResultViewModel$3$1().getType());
                    if (list2 != null && !list2.isEmpty()) {
                        TagVideoEntity tagVideoEntity3 = new TagVideoEntity();
                        tagVideoEntity3.setTagId(5);
                        tagVideoEntity3.setPeopleList(list2);
                        arrayList2.add(tagVideoEntity3);
                    }
                    atomicReference.set(arrayList2);
                    countDownLatch.countDown();
                }
                break;
        }
    }

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