[RoutingOpt]修正车前引导线拖尾问题

[RouterOpt]优化代码逻辑
This commit is contained in:
renwj
2022-04-15 19:37:07 +08:00
parent f184dce4a2
commit 14d32eef0a
16 changed files with 472 additions and 240 deletions

View File

@@ -13,6 +13,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;
@@ -305,6 +308,10 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnCameraChangeListener(null);
CallerLogger.INSTANCE.d(M_MAP+TAG, "map onDestroy");
}
if (mLocationTask != null) {
mainHandler.removeCallbacks(mLocationTask);
}
}
@Override
@@ -662,18 +669,47 @@ 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, 1);
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, 1);
} else {
if (mLocationTask == null) {
mLocationTask = new LocationTask();
}
mLocationTask.setMoGoLocation(currentLocation);
mainHandler.removeCallbacks(mLocationTask);
mainHandler.post(mLocationTask);
}
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());
@@ -687,7 +723,6 @@ public class AMapViewWrapper implements IMogoMapView,
.putString(SharedPrefsConstants.LOCATION_LONGITUDE, String.valueOf(location.getLon()));
}
if (MogoCarLocationChangedListenerRegister.getInstance().getListener() != null) {
MogoCarLocationChangedListenerRegister.getInstance().getListener().onCarLocationChanged2(sysLocation);
}