package com.tencent.mm.plugin.appbrand.jsapi.media;

import com.tencent.map.geolocation.TencentLocationUtils;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.appstorage.AppBrandLocalVideoObject;
import com.tencent.mm.plugin.appbrand.jsapi.media.JsApiChooseMultiMedia.a;
import com.tencent.mm.sdk.platformtools.BackwardSupportUtil.ExifHelper.LatLongData;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;
import java.io.File;
import java.util.Calendar;

class JsApiChooseMultiMedia$a$3 implements Runnable {
    final /* synthetic */ double fBX;
    final /* synthetic */ double fBY;
    final /* synthetic */ a hPN;
    final /* synthetic */ String hPO;

    JsApiChooseMultiMedia$a$3(a aVar, String str, double d, double d2) {
        this.hPN = aVar;
        this.hPO = str;
        this.fBX = d;
        this.fBY = d2;
    }

    public final void run() {
        AppMethodBeat.i(131232);
        if (new File(this.hPO).exists()) {
            ab.i("MicroMsg.JsApiChooseMultiMedia", "take media camera, the mVideoFilePath file exist, success");
            this.hPN.hPK.bFZ = -1;
            AppBrandLocalVideoObject a = a.a(this.hPN, this.hPO, false);
            if (a == null) {
                ab.e("MicroMsg.JsApiChooseMultiMedia", "addVideoItem fail ,mVideoFilePath is %s", new Object[]{this.hPO});
                this.hPN.hPK.bFZ = -2;
                a.e(this.hPN, this.hPN.hPK);
                AppMethodBeat.o(131232);
                return;
            }
            String str;
            String By = a.By(this.hPO);
            String str2 = BuildConfig.FLAVOR;
            if (bo.isNullOrNil(By)) {
                str = str2;
            } else {
                str = a.a(this.hPN, By);
            }
            long timeInMillis = Calendar.getInstance().getTimeInMillis() / 1000;
            double d = -1.0d;
            if (com.tencent.mm.modelgeo.a.r(this.fBX) && com.tencent.mm.modelgeo.a.q(this.fBY)) {
                LatLongData aEl = a.aEl();
                if (aEl != null) {
                    d = TencentLocationUtils.distanceBetween((double) aEl.cEB, (double) aEl.fFz, this.fBX, this.fBY);
                } else {
                    ab.w("MicroMsg.JsApiChooseMultiMedia", "calculate X fail, locData is null. video_Path: %s.", new Object[]{this.hPO});
                }
            } else {
                ab.w("MicroMsg.JsApiChooseMultiMedia", "calculate X fail, lat/long is invalid. video_Path: %s.", new Object[]{this.hPO});
            }
            String a2 = a.a(timeInMillis, d);
            this.hPN.hPK.hPI = a.b(a.czD, (long) a.size, a.width, a.height, a.duration, str, a2);
            a.f(this.hPN, this.hPN.hPK);
            AppMethodBeat.o(131232);
            return;
        }
        ab.e("MicroMsg.JsApiChooseMultiMedia", "take media camera, mVideoFilePath is %s, the file not exist, fail", new Object[]{this.hPO});
        this.hPN.hPK.bFZ = -2;
        a.g(this.hPN, this.hPN.hPK);
        AppMethodBeat.o(131232);
    }
}
