From 99b3d099a2e22610728fd659dd11ca32ecdd8798 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 25 Aug 2017 12:42:29 +0300 Subject: [PATCH] Fix clear selections --- .../MeasurementToolFragment.java | 32 +++++++------------ .../measurementtool/MeasurementToolLayer.java | 6 ++-- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index ecb8c2dbfa..fcf87a813d 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -616,7 +616,8 @@ public class MeasurementToolFragment extends Fragment { if (measurementLayer != null) { removePoint(measurementLayer, editingCtx.getSelectedPointPosition()); } - clearSelection(); + editingCtx.recreateSegments(); + editingCtx.setSelectedPointPosition(-1); } @Override @@ -645,7 +646,7 @@ public class MeasurementToolFragment extends Fragment { @Override public void onClearSelection() { - clearSelection(); + editingCtx.setSelectedPointPosition(-1); } }; } @@ -859,12 +860,10 @@ public class MeasurementToolFragment extends Fragment { int position = editingCtx.getSelectedPointPosition(); commandManager.execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position)); editingCtx.getPoints().add(position, newPoint); - editingCtx.recreateSegments(); doAddOrMovePointCommonStuff(); measurementLayer.exitMovePointMode(false); measurementLayer.refreshMap(); } - clearSelection(); } private void cancelMovePointMode() { @@ -874,8 +873,6 @@ public class MeasurementToolFragment extends Fragment { measurementToolLayer.exitMovePointMode(true); measurementToolLayer.refreshMap(); } - clearSelection(); - editingCtx.recreateSegments(); } private void addPointAfter() { @@ -891,24 +888,24 @@ public class MeasurementToolFragment extends Fragment { private void applyAddPointAfterMode() { switchAddPointAfterMode(false); + editingCtx.setSelectedPointPosition(-1); + editingCtx.recreateSegments(); MeasurementToolLayer measurementLayer = getMeasurementLayer(); if (measurementLayer != null) { measurementLayer.exitAddPointAfterMode(); measurementLayer.refreshMap(); } - clearSelection(); - editingCtx.recreateSegments(); } private void cancelAddPointAfterMode() { switchAddPointAfterMode(false); + editingCtx.setSelectedPointPosition(-1); + editingCtx.recreateSegments(); MeasurementToolLayer measurementToolLayer = getMeasurementLayer(); if (measurementToolLayer != null) { measurementToolLayer.exitAddPointAfterMode(); measurementToolLayer.refreshMap(); } - clearSelection(); - editingCtx.recreateSegments(); } private void addPointBefore() { @@ -923,31 +920,24 @@ public class MeasurementToolFragment extends Fragment { private void applyAddPointBeforeMode() { switchAddPointBeforeMode(false); + editingCtx.setSelectedPointPosition(-1); + editingCtx.recreateSegments(); MeasurementToolLayer measurementLayer = getMeasurementLayer(); if (measurementLayer != null) { measurementLayer.exitAddPointBeforeMode(); measurementLayer.refreshMap(); } - clearSelection(); - editingCtx.recreateSegments(); } private void cancelAddPointBeforeMode() { switchAddPointBeforeMode(false); + editingCtx.setSelectedPointPosition(-1); + editingCtx.recreateSegments(); MeasurementToolLayer measurementToolLayer = getMeasurementLayer(); if (measurementToolLayer != null) { measurementToolLayer.exitAddPointBeforeMode(); measurementToolLayer.refreshMap(); } - clearSelection(); - editingCtx.recreateSegments(); - } - - private void clearSelection() { - MeasurementToolLayer measurementToolLayer = getMeasurementLayer(); - if (measurementToolLayer != null) { - measurementToolLayer.clearSelection(); - } } private void switchMovePointMode(boolean enable) { diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index 33b44d7a8c..92de270b1f 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -129,10 +129,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL return false; } - void clearSelection() { - editingCtx.setSelectedPointPosition(-1); - } - @Override public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) { if (inMeasurementMode) { @@ -323,7 +319,9 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL WptPt pt = editingCtx.getOriginalPointToMove(); editingCtx.getPoints().add(editingCtx.getSelectedPointPosition(), pt); } + editingCtx.recreateSegments(); editingCtx.setOriginalPointToMove(null); + editingCtx.setSelectedPointPosition(-1); } void exitAddPointAfterMode() {