Refactor
This commit is contained in:
parent
b6893b4b46
commit
b5f0af881b
3 changed files with 8 additions and 40 deletions
|
@ -135,30 +135,6 @@ public class MeasurementEditingContext {
|
|||
return after;
|
||||
}
|
||||
|
||||
// public void recreateSegments() {
|
||||
// List<WptPt> points = new ArrayList<>();
|
||||
// points.addAll(before.points);
|
||||
// points.addAll(after.points);
|
||||
// before.points.clear();
|
||||
// if (points.size() > 1) {
|
||||
// for (int i = 0; i < points.size() - 1; i++) {
|
||||
// Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1));
|
||||
// List<WptPt> pts = snappedToRoadPoints.get(pair);
|
||||
// if (pts != null) {
|
||||
// before.points.addAll(pts);
|
||||
// } else {
|
||||
// if (inSnapToRoadMode) {
|
||||
// scheduleRouteCalculateIfNotEmpty();
|
||||
// }
|
||||
// before.points.addAll(Arrays.asList(pair.first, pair.second));
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// before.points.addAll(points);
|
||||
// }
|
||||
// after.points.clear();
|
||||
// }
|
||||
|
||||
public List<WptPt> getPoints() {
|
||||
return getBeforePoints();
|
||||
}
|
||||
|
@ -168,7 +144,7 @@ public class MeasurementEditingContext {
|
|||
}
|
||||
|
||||
public List<WptPt> getAfterPoints() {
|
||||
return after.points;
|
||||
return after.points;
|
||||
}
|
||||
|
||||
public int getPointsCount() {
|
||||
|
@ -180,9 +156,13 @@ public class MeasurementEditingContext {
|
|||
points.addAll(before.points);
|
||||
points.addAll(after.points);
|
||||
before.points.clear();
|
||||
before.points.addAll(points.subList(0, position));
|
||||
after.points.clear();
|
||||
after.points.addAll(points.subList(position, points.size()));
|
||||
if (position == before.points.size() + after.points.size()) {
|
||||
before.points.addAll(points);
|
||||
} else {
|
||||
before.points.addAll(points.subList(0, position));
|
||||
after.points.addAll(points.subList(position, points.size()));
|
||||
}
|
||||
}
|
||||
|
||||
public void addPoint(WptPt pt) {
|
||||
|
@ -283,7 +263,6 @@ public class MeasurementEditingContext {
|
|||
pts.add(pt);
|
||||
}
|
||||
snappedToRoadPoints.put(currentPair, pts);
|
||||
// recreateSegments();
|
||||
progressListener.refreshMap();
|
||||
if (!snapToRoadPairsToCalculate.isEmpty()) {
|
||||
application.getRoutingHelper().startRouteCalculationThread(getParams(), true, true);
|
||||
|
|
|
@ -303,7 +303,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
editingCtx.getCommandManager().undo();
|
||||
// editingCtx.recreateSegments();
|
||||
if (editingCtx.getCommandManager().canUndo()) {
|
||||
enable(undoBtn);
|
||||
} else {
|
||||
|
@ -324,7 +323,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
editingCtx.getCommandManager().redo();
|
||||
// editingCtx.recreateSegments();
|
||||
if (editingCtx.getCommandManager().canRedo()) {
|
||||
enable(redoBtn);
|
||||
} else {
|
||||
|
@ -595,7 +593,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void clearAllOnClick() {
|
||||
editingCtx.getCommandManager().execute(new ClearPointsCommand(measurementLayer));
|
||||
editingCtx.clearSegments();
|
||||
editingCtx.cancelSnapToRoad();
|
||||
if (pointsListOpened) {
|
||||
hidePointsList();
|
||||
|
@ -625,7 +622,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
if (measurementLayer != null) {
|
||||
removePoint(measurementLayer, editingCtx.getSelectedPointPosition());
|
||||
}
|
||||
// editingCtx.recreateSegments();
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
}
|
||||
|
||||
|
@ -682,7 +678,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
|
||||
private void removePoint(MeasurementToolLayer layer, int position) {
|
||||
editingCtx.getCommandManager().execute(new RemovePointCommand(layer, position));
|
||||
// editingCtx.recreateSegments();
|
||||
adapter.notifyDataSetChanged();
|
||||
disable(redoBtn);
|
||||
updateText();
|
||||
|
@ -749,7 +744,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
toPosition = holder.getAdapterPosition();
|
||||
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
||||
editingCtx.getCommandManager().execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
|
||||
// editingCtx.recreateSegments();
|
||||
adapter.notifyDataSetChanged();
|
||||
disable(redoBtn);
|
||||
updateText();
|
||||
|
@ -868,7 +862,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
WptPt oldPoint = editingCtx.getOriginalPointToMove();
|
||||
int position = editingCtx.getSelectedPointPosition();
|
||||
editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position));
|
||||
editingCtx.addPoint(newPoint);
|
||||
doAddOrMovePointCommonStuff();
|
||||
measurementLayer.exitMovePointMode(false);
|
||||
measurementLayer.refreshMap();
|
||||
|
@ -898,7 +891,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private void applyAddPointAfterMode() {
|
||||
switchAddPointAfterMode(false);
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
// editingCtx.recreateSegments();
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
measurementLayer.exitAddPointAfterMode();
|
||||
|
@ -909,7 +901,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private void cancelAddPointAfterMode() {
|
||||
switchAddPointAfterMode(false);
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
// editingCtx.recreateSegments();
|
||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
||||
if (measurementToolLayer != null) {
|
||||
measurementToolLayer.exitAddPointAfterMode();
|
||||
|
@ -930,7 +921,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private void applyAddPointBeforeMode() {
|
||||
switchAddPointBeforeMode(false);
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
// editingCtx.recreateSegments();
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
measurementLayer.exitAddPointBeforeMode();
|
||||
|
@ -941,7 +931,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private void cancelAddPointBeforeMode() {
|
||||
switchAddPointBeforeMode(false);
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
// editingCtx.recreateSegments();
|
||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
||||
if (measurementToolLayer != null) {
|
||||
measurementToolLayer.exitAddPointBeforeMode();
|
||||
|
|
|
@ -327,9 +327,9 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
WptPt pt = editingCtx.getOriginalPointToMove();
|
||||
editingCtx.addPoint(pt);
|
||||
}
|
||||
// editingCtx.recreateSegments();
|
||||
editingCtx.setOriginalPointToMove(null);
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||
}
|
||||
|
||||
void exitAddPointAfterMode() {
|
||||
|
|
Loading…
Reference in a new issue