package xyz.netfly.ads;

import com.bytedance.sdk.openadsdk.api.init.PAGConfig;
import com.bytedance.sdk.openadsdk.api.init.PAGSdk;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.lang.reflect.Type;
import java.util.Map;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.api.entity.PangleConfigEntity;
import xyz.stream.utils.f0;

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

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

    public l(r rVar) {
        this.f34865a = rVar;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
    }

    @Override // xyz.stream.api.e
    public final void onSuccess(Object obj) {
        Object obj2;
        Map map;
        BaseEntity baseEntity = (BaseEntity) obj;
        if (baseEntity == null || baseEntity.getCode() != 200 || baseEntity.getData() == null) {
            return;
        }
        JsonElement data = baseEntity.getData();
        Type type = new PangleController$2$1().getType();
        Gson gson = xyz.stream.utils.m.f36162a;
        Map map2 = (Map) gson.fromJson(data, type);
        if (map2 == null || (obj2 = map2.get("pangle_config")) == null || (map = (Map) gson.fromJson(gson.toJsonTree(obj2), new PangleController$2$2().getType())) == null) {
            return;
        }
        boolean z10 = xyz.stream.utils.e.d().f36121j;
        r rVar = this.f34865a;
        if (z10) {
            Object obj3 = map.get("phone");
            if (obj3 != null) {
                rVar.f34890e = (PangleConfigEntity) gson.fromJson(gson.toJsonTree(obj3), PangleConfigEntity.class);
            }
        } else {
            Object obj4 = map.get("pad");
            if (obj4 != null) {
                rVar.f34890e = (PangleConfigEntity) gson.fromJson(gson.toJsonTree(obj4), PangleConfigEntity.class);
            }
        }
        if (rVar.f34890e == null) {
            return;
        }
        rVar.f34893h = System.currentTimeMillis();
        f0.o().B(rVar.f34890e, "sp_pangle_config");
        PAGConfig pAGConfigB = rVar.b();
        if (pAGConfigB == null) {
            return;
        }
        if (PAGSdk.isInitSuccess() && pAGConfigB.getAppId().equals(rVar.f34891f)) {
            return;
        }
        PAGSdk.init(rVar.f34886a, pAGConfigB, new k(this, pAGConfigB));
    }
}
