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

import com.mbridge.msdk.foundation.entity.h;
import com.mbridge.msdk.foundation.tools.af;
import org.json.JSONObject;
/* compiled from: Listener.java */
/* loaded from: classes5.dex */
public class c<T> implements b<T> {
    private long startTime;
    public int adType = 0;
    public String placementId = "";
    public String unitId = "";
    private com.mbridge.msdk.foundation.same.report.a.b mRequestTime = null;

    public void onCancel() {
    }

    @Override // com.mbridge.msdk.foundation.same.net.b
    public void onError(com.mbridge.msdk.foundation.same.net.a.a aVar) {
    }

    public void onFinish() {
    }

    public void onNetworking() {
    }

    public void onProgressChange(long j, long j2) {
    }

    public void onRetry() {
    }

    public void setAdType(int i) {
        this.adType = i;
    }

    public void setPlacementId(String str) {
        this.placementId = str;
    }

    public void setUnitId(String str) {
        this.unitId = str;
    }

    public void calcRequestTime(long j) {
        com.mbridge.msdk.foundation.same.report.a.b bVar = new com.mbridge.msdk.foundation.same.report.a.b(new h());
        this.mRequestTime = bVar;
        bVar.b(this.unitId);
        this.mRequestTime.b(1);
        this.mRequestTime.a((j - this.startTime) + "");
    }

    public void onPreExecute() {
        this.startTime = System.currentTimeMillis();
    }

    @Override // com.mbridge.msdk.foundation.same.net.b
    public void onSuccess(d<T> dVar) {
        try {
            String str = com.mbridge.msdk.foundation.controller.c.m().k() + "_" + this.placementId + "_" + this.unitId + "_" + this.adType;
            com.mbridge.msdk.c.h.a();
            af.b("Listener", dVar.c + " " + str);
            if (dVar.c instanceof JSONObject) {
                com.mbridge.msdk.foundation.same.net.e.c.a().a(str, ((JSONObject) dVar.c).optInt("status"), ((JSONObject) dVar.c).toString(), System.currentTimeMillis());
            }
            if (dVar.c instanceof String) {
                com.mbridge.msdk.foundation.same.net.e.c.a().a(str, new JSONObject((String) dVar.c).optInt("status"), (String) dVar.c, System.currentTimeMillis());
            }
        } catch (Exception e) {
            af.b("Listener", e.getMessage());
        }
    }

    public void saveHbState(int i) {
        com.mbridge.msdk.foundation.same.report.a.b bVar = this.mRequestTime;
        if (bVar != null) {
            bVar.c(i);
        }
    }

    public void saveRequestTime(int i) {
        com.mbridge.msdk.foundation.same.report.a.b bVar = this.mRequestTime;
        if (bVar != null) {
            bVar.a(i);
            this.mRequestTime.a();
        }
    }
}
