Fix adding point after
This commit is contained in:
parent
923614a239
commit
c9ec0df1d1
2 changed files with 21 additions and 15 deletions
|
@ -865,7 +865,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private void addPointAfter() {
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null && positionToAddPoint != -1) {
|
||||
addPointToPosition(positionToAddPoint);
|
||||
if (addPointToPosition(positionToAddPoint)) {
|
||||
selectedPointPos += 1;
|
||||
selectedCachedPoint = new WptPt(measurementLayer.getMeasurementPoints().get(selectedPointPos));
|
||||
measurementLayer.setSelectedPointPos(selectedPointPos);
|
||||
|
@ -874,6 +874,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
positionToAddPoint += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyAddPointAfterMode() {
|
||||
if (inAddPointAfterMode) {
|
||||
|
@ -906,13 +907,14 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private void addPointBefore() {
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null && positionToAddPoint != -1) {
|
||||
addPointToPosition(positionToAddPoint);
|
||||
if (addPointToPosition(positionToAddPoint)) {
|
||||
selectedCachedPoint = new WptPt(measurementLayer.getMeasurementPoints().get(selectedPointPos));
|
||||
measurementLayer.setSelectedPointPos(selectedPointPos);
|
||||
measurementLayer.setSelectedCachedPoint(selectedCachedPoint);
|
||||
measurementLayer.refreshMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyAddPointBeforeMode() {
|
||||
if (inAddPointBeforeMode) {
|
||||
|
@ -1013,16 +1015,18 @@ public class MeasurementToolFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void addPointToPosition(int position) {
|
||||
private boolean addPointToPosition(int position) {
|
||||
boolean added = false;
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
commandManager.execute(new AddPointCommand(measurementLayer, position));
|
||||
added = commandManager.execute(new AddPointCommand(measurementLayer, position));
|
||||
enable(undoBtn, upDownBtn);
|
||||
disable(redoBtn);
|
||||
updateText();
|
||||
adapter.notifyDataSetChanged();
|
||||
saved = false;
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
private void showPointsList() {
|
||||
|
|
|
@ -18,11 +18,13 @@ public class MeasurementCommandManager {
|
|||
return redoCommands.size() > 0;
|
||||
}
|
||||
|
||||
public void execute(MeasurementModeCommand command) {
|
||||
public boolean execute(MeasurementModeCommand command) {
|
||||
if (command.execute()) {
|
||||
undoCommands.push(command);
|
||||
redoCommands.clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
|
|
Loading…
Reference in a new issue