package xyz.netfly.player;

import clientgosdk.Clientgosdk;
import ie.c4;
import java.util.List;
import kotlinx.coroutines.y;
import xyz.netfly.ui.live.tablet.LivePlayActivity;
import xyz.netfly.ui.live.tv.LiveActivity;
import xyz.stream.api.entity.AiSubtitleResult;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.api.entity.SubtitlePlayEntity;
import xyz.stream.utils.entity.CheckResultEntity;
import xyz.stream.utils.event.CheckEvent;
import xyz.stream.utils.event.LogoutEvent;
import xyz.stream.utils.f0;

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

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

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

    public /* synthetic */ i(Object obj, int i10) {
        this.f35201a = i10;
        this.f35202b = obj;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        int i10 = this.f35201a;
        Object obj = this.f35202b;
        switch (i10) {
            case 0:
                xyz.stream.utils.h.c("Error fetching AI subtitle result: " + str);
                break;
            case 1:
                ((LivePlayActivity) obj).runOnUiThread(new xyz.netfly.ads.h(this, 16));
                break;
            case 2:
                ((LiveActivity) obj).runOnUiThread(new xyz.netfly.ads.h(this, 17));
                break;
        }
    }

    public final void b(List list) {
        int i10 = this.f35201a;
        Object obj = this.f35202b;
        switch (i10) {
            case 1:
                ((LivePlayActivity) obj).runOnUiThread(new com.tekartik.sqflite.g(this, list, 28));
                break;
            default:
                ((LiveActivity) obj).runOnUiThread(new ve.b(this, list, 1));
                break;
        }
    }

    public final void c(BaseEntity baseEntity) {
        switch (this.f35201a) {
            case 0:
                Object obj = this.f35202b;
                if (baseEntity != null) {
                    try {
                        if (baseEntity.getData() != null) {
                            AiSubtitleResult aiSubtitleResult = (AiSubtitleResult) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), AiSubtitleResult.class);
                            if (aiSubtitleResult != null) {
                                int iIntValue = aiSubtitleResult.getProgress().intValue();
                                if (((n) obj).f35238x != null) {
                                    g gVar = ((n) obj).f35238x;
                                    ((c4) gVar.f35198b).f26735b.post(new i0.o(iIntValue, 7, gVar));
                                }
                                if (((n) obj).f35223i != null && ((n) obj).f35223i.get() != null && ((n) obj).f35238x == null && ((n) obj).f35227m != null && !((n) obj).f35227m.isEmpty()) {
                                    ((wf.a) ((n) obj).f35223i.get()).a(iIntValue, ((SubtitlePlayEntity) ((n) obj).f35227m.get(0)).getTitle());
                                }
                                if (iIntValue >= 100) {
                                    if (((n) obj).f35238x != null) {
                                        Object obj2 = ((n) obj).f35238x.f35197a;
                                        if (((e.m) obj2).isShowing()) {
                                            ((e.m) obj2).dismiss();
                                        }
                                    }
                                    if (((n) obj).o()) {
                                        ((n) obj).f35233s.runOnUiThread(new com.tekartik.sqflite.g(this, aiSubtitleResult, 20));
                                    }
                                }
                            }
                        }
                    } catch (Exception e10) {
                        u.a.g(e10, new StringBuilder("Error parsing AI subtitle result: "));
                        return;
                    }
                }
                break;
            default:
                xyz.stream.utils.h.b("checkPlan onSuccess: " + xyz.stream.utils.m.a(baseEntity));
                if (baseEntity.getCode() == 200) {
                    CheckResultEntity checkResultEntity = (CheckResultEntity) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), CheckResultEntity.class);
                    if (checkResultEntity != null) {
                        checkResultEntity.setIsVip(0);
                        xyz.stream.utils.e.d().j(checkResultEntity);
                        f0.o().w("sp_account", checkResultEntity.getEmail());
                        if (checkResultEntity.getUnid() == null || checkResultEntity.getUnid().isEmpty() || checkResultEntity.getUnid().equals("null")) {
                            f0.o().v(1, "sp_account_type");
                        } else {
                            f0.o().w("flutter.spUnid", checkResultEntity.getUnid());
                            f0.o().v(0, "sp_account_type");
                        }
                        xyz.stream.api.q qVarG = xyz.stream.api.q.g();
                        String strQ = y.q(xyz.stream.utils.e.d().f36112a);
                        int iIntValue2 = checkResultEntity.getIsPremium() != null ? checkResultEntity.getIsPremium().intValue() : 0;
                        qVarG.getClass();
                        Clientgosdk.setAppInfo(strQ, iIntValue2);
                        fe.d.b().h(new CheckEvent(checkResultEntity));
                    } else {
                        xyz.stream.utils.e.d().j(null);
                        fe.d.b().h(new CheckEvent(null));
                    }
                } else if (baseEntity.getCode() != 401) {
                    xyz.stream.utils.e.d().j(null);
                    fe.d.b().h(new CheckEvent(null));
                } else {
                    f0.o().y("flutter.spUnid");
                    xyz.stream.utils.e.d().j(null);
                    f0.o().y("sp_is_login_new");
                    f0.o().y("sp_account");
                    f0.o().y("sp_token");
                    f0.o().y("flutter.selectRoles");
                    f0.o().y("flutter.role_entity");
                    fe.d.b().h(new CheckEvent(null));
                    fe.d.b().h(new LogoutEvent(false));
                }
                break;
        }
    }

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