%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD.apk(点击下载) / gz.java


package com.amap.api.col.p0003s;

import android.content.Context;
import android.os.Handler;
import com.amap.api.maps.model.LatLng;
import com.amap.api.trace.TraceLocation;
import com.taobao.weex.common.Constants;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* renamed from: com.amap.api.col.3s.gz  reason: invalid package */
/* compiled from: TraceHandlerAbstract */
public final class gz extends gx<List<TraceLocation>, List<LatLng>> implements Runnable {
    private List<TraceLocation> j;
    private Handler k = null;
    private int l = 0;
    private int m = 0;
    private String n;

    @Override // com.amap.api.col.p0003s.jq
    public final boolean isSupportIPV6() {
        return true;
    }

    /* Return type fixed from 'java.lang.Object' to match base method */
    /* access modifiers changed from: protected */
    @Override // com.amap.api.col.p0003s.gx, com.amap.api.col.p0003s.gw
    public final /* synthetic */ List<LatLng> a(String str) throws gv {
        return b(str);
    }

    public gz(Context context, Handler handler, List<TraceLocation> list, String str, int i, int i2) {
        super(context, list);
        this.j = list;
        this.k = handler;
        this.m = i;
        this.l = i2;
        this.n = str;
    }

    /* access modifiers changed from: protected */
    @Override // com.amap.api.col.p0003s.gx, com.amap.api.col.p0003s.gw
    public final String c() {
        JSONArray jSONArray = new JSONArray();
        long j2 = 0;
        for (int i = 0; i < this.j.size(); i++) {
            TraceLocation traceLocation = this.j.get(i);
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put(Constants.Name.X, traceLocation.getLongitude());
                jSONObject.put(Constants.Name.Y, traceLocation.getLatitude());
                jSONObject.put("ag", (int) traceLocation.getBearing());
                long time = traceLocation.getTime();
                if (i == 0) {
                    if (time == 0) {
                        time = (System.currentTimeMillis() - 10000) / 1000;
                    }
                    jSONObject.put("tm", time / 1000);
                } else {
                    if (time != 0) {
                        long j3 = time - j2;
                        if (j3 >= 1000) {
                            jSONObject.put("tm", j3 / 1000);
                        }
                    }
                    jSONObject.put("tm", 1);
                }
                j2 = time;
                jSONObject.put("sp", (int) traceLocation.getSpeed());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            jSONArray.put(jSONObject);
        }
        this.h = getURL() + "&" + jSONArray.toString();
        return jSONArray.toString();
    }

    private static List<LatLng> b(String str) throws gv {
        JSONArray optJSONArray;
        ArrayList arrayList = new ArrayList();
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (jSONObject.has("data") && (optJSONArray = jSONObject.optJSONObject("data").optJSONArray("points")) != null) {
                if (optJSONArray.length() != 0) {
                    for (int i = 0; i < optJSONArray.length(); i++) {
                        JSONObject optJSONObject = optJSONArray.optJSONObject(i);
                        arrayList.add(new LatLng(Double.parseDouble(optJSONObject.optString(Constants.Name.Y)), Double.parseDouble(optJSONObject.optString(Constants.Name.X))));
                    }
                    return arrayList;
                }
            }
            return arrayList;
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public final void run() {
        new ArrayList();
        try {
            hb.a().a(this.n, this.l, (List) d());
            hb.a().a(this.n).a(this.k);
        } catch (gv e) {
            hb.a();
            hb.a(this.k, this.m, e.a());
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    @Override // com.amap.api.col.p0003s.jq
    public final String getURL() {
        String str = "key=" + he.f(this.g);
        String a = hh.a();
        return "http://restsdk.amap.com/v4/grasproad/driving?" + str + "&ts=".concat(String.valueOf(a)) + "&scode=".concat(String.valueOf(hh.a(this.g, a, str)));
    }

    @Override // com.amap.api.col.p0003s.jq
    public final String getIPV6URL() {
        return dl.a(getURL());
    }
}