package d.f.a.r2.j3;

import android.text.TextUtils;
import com.google.gson.JsonParseException;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
import okhttp3.Response;

/* JADX INFO: compiled from: OkHttpHelper.java */
/* JADX INFO: loaded from: classes.dex */
public class d implements Callback {
    public final /* synthetic */ c a;

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

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

    public d(e eVar, c cVar, Request request) {
        this.f3243c = eVar;
        this.a = cVar;
        this.f3242b = request;
    }

    @Override // okhttp3.Callback
    public void onFailure(Call call, IOException iOException) {
        this.a.onFailure(this.f3242b, iOException);
    }

    @Override // okhttp3.Callback
    public void onResponse(Call call, final Response response) throws IOException {
        this.a.onResponse(response);
        if (!response.isSuccessful()) {
            e eVar = this.f3243c;
            final c cVar = this.a;
            final Exception exc = null;
            eVar.f3247e.post(new Runnable() { // from class: d.f.a.r2.j3.a
                @Override // java.lang.Runnable
                public final void run() {
                    c cVar2 = cVar;
                    Response response2 = response;
                    cVar2.onError(response2, response2.code(), exc);
                }
            });
            return;
        }
        final String strString = response.body().string();
        d.b.a.a.a.N("result=", strString, "OkHttpHelper");
        if (this.a.mType == String.class || TextUtils.isEmpty(strString)) {
            e eVar2 = this.f3243c;
            final c cVar2 = this.a;
            eVar2.f3247e.post(new Runnable() { // from class: d.f.a.r2.j3.b
                @Override // java.lang.Runnable
                public final void run() {
                    cVar2.onSuccess(response, strString);
                }
            });
            return;
        }
        try {
            final Object objFromJson = this.f3243c.f3246d.fromJson(strString, this.a.mType);
            e eVar3 = this.f3243c;
            final c cVar3 = this.a;
            eVar3.f3247e.post(new Runnable() { // from class: d.f.a.r2.j3.b
                @Override // java.lang.Runnable
                public final void run() {
                    cVar3.onSuccess(response, objFromJson);
                }
            });
        } catch (JsonParseException e2) {
            this.a.onError(response, response.code(), e2);
        }
    }
}
