package com.mbridge.msdk.foundation.same.net.f;

import android.text.TextUtils;
import androidx.core.app.NotificationCompat;
import com.mbridge.msdk.foundation.tools.af;
import org.json.JSONObject;
/* compiled from: CommonMBListener.java */
/* loaded from: classes5.dex */
public abstract class d extends com.mbridge.msdk.foundation.same.net.c<JSONObject> {

    /* renamed from: a  reason: collision with root package name */
    private static final String f3647a = "d";

    public abstract void a(String str);

    public abstract void a(JSONObject jSONObject);

    @Override // com.mbridge.msdk.foundation.same.net.c, com.mbridge.msdk.foundation.same.net.b
    public void onError(com.mbridge.msdk.foundation.same.net.a.a aVar) {
        af.b(f3647a, "errorCode = " + aVar.f3631a);
        a(com.mbridge.msdk.foundation.same.net.e.a.a(aVar));
    }

    @Override // com.mbridge.msdk.foundation.same.net.c, com.mbridge.msdk.foundation.same.net.b
    public void onSuccess(com.mbridge.msdk.foundation.same.net.d<JSONObject> dVar) {
        if (dVar == null) {
            a("response is null");
            return;
        }
        super.onSuccess(dVar);
        if (dVar.b == null) {
            a(dVar);
        } else if (dVar.b.d == 204) {
            a(new JSONObject());
        } else {
            a(dVar);
        }
    }

    private void a(com.mbridge.msdk.foundation.same.net.d<JSONObject> dVar) {
        if (dVar.c == null) {
            a("response result is null");
            return;
        }
        int optInt = dVar.c.optInt("status", -9999);
        if (optInt == -9999) {
            a(dVar.c);
        } else if (optInt == 1 || optInt == 200) {
            a(dVar.c.optJSONObject("data"));
        } else {
            String optString = dVar.c.optString(NotificationCompat.CATEGORY_MESSAGE);
            if (TextUtils.isEmpty(optString)) {
                optString = "error message is null";
            }
            a(optString);
        }
    }
}
