package xyz.stream.api;

import com.google.gson.JsonElement;
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.CheckUpdateEntity;

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

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

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

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

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

    public /* synthetic */ c(Object obj, AtomicReference atomicReference, CountDownLatch countDownLatch, int i10) {
        this.f35762a = i10;
        this.f35765d = obj;
        this.f35763b = atomicReference;
        this.f35764c = countDownLatch;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        int i10 = this.f35762a;
        AtomicReference atomicReference = this.f35763b;
        CountDownLatch countDownLatch = this.f35764c;
        switch (i10) {
            case 0:
                countDownLatch.countDown();
                break;
            case 1:
                atomicReference.set(null);
                countDownLatch.countDown();
                break;
            default:
                atomicReference.set(null);
                countDownLatch.countDown();
                break;
        }
    }

    public final void b(BaseEntity baseEntity) {
        int i10 = this.f35762a;
        AtomicReference atomicReference = this.f35763b;
        JsonElement jsonElement = null;
        CountDownLatch countDownLatch = this.f35764c;
        switch (i10) {
            case 0:
                if (baseEntity != null && baseEntity.getData() != null) {
                    JsonElement data = baseEntity.getData();
                    if (data != null && data.isJsonObject()) {
                        jsonElement = data.getAsJsonObject().get("list");
                    }
                    if (jsonElement != null && !jsonElement.isJsonNull()) {
                        atomicReference.set((List) xyz.stream.utils.m.f36162a.fromJson(jsonElement, new ApiDataCacheHelper$5$1().getType()));
                        countDownLatch.countDown();
                        break;
                    }
                }
                break;
            case 1:
                if (baseEntity == null || baseEntity.getData() == null) {
                    atomicReference.set(null);
                    countDownLatch.countDown();
                } else {
                    try {
                        atomicReference.set((List) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), new RemoteApiHelper$41$1().getType()));
                        countDownLatch.countDown();
                    } catch (Exception e10) {
                        xyz.stream.utils.h.c(e10.getMessage());
                        atomicReference.set(null);
                        countDownLatch.countDown();
                        return;
                    }
                }
                break;
            default:
                if (baseEntity == null || baseEntity.getData() == null) {
                    atomicReference.set(null);
                    countDownLatch.countDown();
                } else {
                    try {
                        CheckUpdateEntity checkUpdateEntity = (CheckUpdateEntity) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), CheckUpdateEntity.class);
                        if (checkUpdateEntity == null || checkUpdateEntity.getVersion() == null) {
                            checkUpdateEntity = null;
                        }
                        atomicReference.set(checkUpdateEntity);
                        countDownLatch.countDown();
                    } catch (Exception unused) {
                        atomicReference.set(null);
                        countDownLatch.countDown();
                        return;
                    }
                }
                break;
        }
    }

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