[RouterOpt]车前引导线拖尾问题优化2

This commit is contained in:
renwj
2022-04-11 18:05:29 +08:00
parent c946f7ca94
commit a0f0d3c2c8
9 changed files with 280 additions and 180 deletions

View File

@@ -12,6 +12,9 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.os.Trace;
import android.text.TextUtils;
import android.util.Log;
@@ -286,6 +289,9 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnCameraChangeListener(null);
CallerLogger.INSTANCE.d(TAG, "map onDestroy");
}
if (mLocationTask != null) {
mainHandler.removeCallbacks(mLocationTask);
}
}
@Override
@@ -666,18 +672,52 @@ public class AMapViewWrapper implements IMogoMapView,
return ObjectUtils.transformCenterLine(MapDataApi.INSTANCE.getCenterLineInfo(lon, lat, angle));
}
private static class LocationTask implements Runnable {
private MogoLocation location;
public void setMoGoLocation(MogoLocation location) {
this.location = location;
}
@Override
public void run() {
if (location != null) {
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(location);
location = null;
}
}
}
private volatile LocationTask mLocationTask;
private final Handler mainHandler = new Handler(Looper.getMainLooper());
@Override
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
MogoLocation mLastLocation = ObjectUtils.fromLocation(location);
UiThreadHandler.post(() -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation));
MogoLocation currentLocation = ObjectUtils.fromLocation(location);
if (Looper.myLooper() == Looper.getMainLooper()) {
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(currentLocation);
} else {
if (mLocationTask == null) {
mLocationTask = new LocationTask();
}
mLocationTask.setMoGoLocation(currentLocation);
mainHandler.removeCallbacks(mLocationTask);
mainHandler.post(mLocationTask);
}
long start = SystemClock.elapsedRealtime();
Location sysLocation = new Location(location.getProvider());
sysLocation.setAltitude(location.getAltitude());
sysLocation.setLatitude(location.getLat());
sysLocation.setLongitude(location.getLon());
sysLocation.setProvider(location.getProvider());
sysLocation.setAccuracy(location.getAcceleration());
sysLocation.setTime(location.getDuration());
sysLocation.setTime(location.duration);
sysLocation.setBearing((float) location.getHeading());
sysLocation.setSpeed(location.getSpeed());
@@ -691,7 +731,6 @@ public class AMapViewWrapper implements IMogoMapView,
.putString(SharedPrefsConstants.LOCATION_LONGITUDE, String.valueOf(location.getLon()));
}
if (MogoCarLocationChangedListenerRegister.getInstance().getListener() != null) {
MogoCarLocationChangedListenerRegister.getInstance().getListener().onCarLocationChanged2(sysLocation);
}
@@ -711,6 +750,7 @@ public class AMapViewWrapper implements IMogoMapView,
CallerLogger.INSTANCE.d(TAG, "同步定位:" + GsonUtils.toJson(location));
}
}
Log.d("TTTTT", "xxxxx:" + (SystemClock.elapsedRealtime() - start));
}
@Override