package xyz.stream.api.viewmodel;

import android.app.Activity;
import tv.danmaku.ijk.media.player.IjkEventListener;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.api.entity.LoginEntity;
import xyz.stream.utils.f0;

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

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

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

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

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

    public /* synthetic */ q(LoginViewModel loginViewModel, String str, Activity activity, int i10) {
        this.f35998a = i10;
        this.f36001d = loginViewModel;
        this.f35999b = str;
        this.f36000c = activity;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        int i10 = this.f35998a;
        LoginViewModel loginViewModel = this.f36001d;
        Activity activity = this.f36000c;
        switch (i10) {
            case 0:
                loginViewModel.handleError(activity, str);
                BaseEntity baseEntity = new BaseEntity();
                baseEntity.setCode(IjkEventListener.BUFFERING_START);
                baseEntity.setMsg(str);
                loginViewModel.loginLiveData.j(baseEntity);
                break;
            default:
                loginViewModel.handleError(activity, str);
                loginViewModel.quickLoginLiveData.j(Boolean.FALSE);
                break;
        }
    }

    public final void b(BaseEntity baseEntity) {
        int i10 = this.f35998a;
        LoginViewModel loginViewModel = this.f36001d;
        int i11 = 0;
        String account = this.f35999b;
        switch (i10) {
            case 0:
                if (baseEntity.getCode() == 200) {
                    LoginEntity loginEntity = (LoginEntity) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), LoginEntity.class);
                    f0.o().w("sp_token", loginEntity.getToken());
                    f0.o().u("sp_is_login_new", Boolean.TRUE);
                    f0.o().w("sp_account", account);
                    f0.o().v(0, "sp_account_type");
                    f0.o().w("flutter.spUnid", loginEntity.getUnid());
                } else if (baseEntity.getCode() != 404) {
                    loginViewModel.handleError(this.f36000c, baseEntity.getMsg());
                }
                loginViewModel.loginLiveData.j(baseEntity);
                break;
            default:
                if (baseEntity.getCode() == 200) {
                    LoginEntity loginEntity2 = (LoginEntity) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), LoginEntity.class);
                    f0.o().w("sp_token", loginEntity2.getToken());
                    f0 f0VarO = f0.o();
                    Boolean bool = Boolean.TRUE;
                    f0VarO.u("sp_is_login_new", bool);
                    f0 f0VarO2 = f0.o();
                    if (account != null && !account.isEmpty()) {
                        i11 = 1;
                    }
                    f0VarO2.v(i11, "sp_account_type");
                    f0 f0VarO3 = f0.o();
                    if (account == null || account.isEmpty()) {
                        account = loginEntity2.getAccount();
                    }
                    f0VarO3.w("sp_account", account);
                    f0.o().w("flutter.spUnid", loginEntity2.getUnid());
                    loginViewModel.quickLoginLiveData.j(bool);
                }
                break;
        }
    }

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