Fix clear all with snap to road

This commit is contained in:
Alex 2017-08-27 10:45:59 +03:00
parent 0395e35999
commit fcfe307ec2
2 changed files with 18 additions and 1 deletions

View file

@ -38,6 +38,7 @@ public class MeasurementEditingContext {
private WptPt originalPointToMove;
private boolean inSnapToRoadMode;
private boolean needUpdateCacheForSnap;
private SnapToRoadProgressListener progressListener;
private ApplicationMode snapToRoadAppMode;
private RouteCalculationProgress calculationProgress;
@ -56,6 +57,15 @@ public class MeasurementEditingContext {
return inSnapToRoadMode;
}
public boolean isNeedUpdateCacheForSnap() {
return needUpdateCacheForSnap;
}
public void setNeedUpdateCacheForSnap(boolean needUpdateCacheForSnap) {
this.needUpdateCacheForSnap = needUpdateCacheForSnap;
updateCacheForSnapIfNeeded(true);
}
int getSelectedPointPosition() {
return selectedPointPosition;
}
@ -168,9 +178,11 @@ public class MeasurementEditingContext {
after.points.clear();
beforeCacheForSnap = null;
afterCacheForSnap = null;
needUpdateCacheForSnap = false;
}
void scheduleRouteCalculateIfNotEmpty() {
needUpdateCacheForSnap = true;
if (application == null || (before.points.size() < 1 && after.points.size() < 1)) {
return;
}
@ -219,7 +231,7 @@ public class MeasurementEditingContext {
}
private void updateCacheForSnapIfNeeded(boolean both) {
if (inSnapToRoadMode) {
if (needUpdateCacheForSnap) {
recreateCacheForSnap(beforeCacheForSnap = new TrkSegment(), before);
if (both) {
recreateCacheForSnap(afterCacheForSnap = new TrkSegment(), after);

View file

@ -9,6 +9,7 @@ import java.util.List;
public class ClearPointsCommand extends MeasurementModeCommand {
private List<WptPt> points;
private boolean needUpdateCache;
public ClearPointsCommand(MeasurementToolLayer measurementLayer) {
this.measurementLayer = measurementLayer;
@ -17,6 +18,7 @@ public class ClearPointsCommand extends MeasurementModeCommand {
@Override
public boolean execute() {
List<WptPt> pts = measurementLayer.getEditingCtx().getPoints();
needUpdateCache = measurementLayer.getEditingCtx().isNeedUpdateCacheForSnap();
points = new LinkedList<>(pts);
pts.clear();
measurementLayer.getEditingCtx().clearSegments();
@ -27,6 +29,9 @@ public class ClearPointsCommand extends MeasurementModeCommand {
@Override
public void undo() {
measurementLayer.getEditingCtx().addPoints(points);
if (needUpdateCache) {
measurementLayer.getEditingCtx().setNeedUpdateCacheForSnap(true);
}
measurementLayer.refreshMap();
}