Revert moveMapToPoint and fix moving
This commit is contained in:
parent
74f3da881b
commit
2e1875373a
2 changed files with 13 additions and 22 deletions
|
@ -606,8 +606,8 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void addPointAfterOnClick() {
|
||||
if (measurementLayer != null) {
|
||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition() + 1);
|
||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_after));
|
||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_addpoint_above));
|
||||
|
@ -617,8 +617,8 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void addPointBeforeOnClick() {
|
||||
if (measurementLayer != null) {
|
||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_before));
|
||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_addpoint_below));
|
||||
|
|
|
@ -367,26 +367,17 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
view.getAnimatedDraggingThread().startMoving(lat, lon, view.getZoom(), true);
|
||||
}
|
||||
|
||||
public void moveMapToPoint(int pos) {
|
||||
if (editingCtx.getBeforePoints().size() > 0 || editingCtx.getAfterPoints().size() > 0) {
|
||||
WptPt pt = null;
|
||||
if (pos >= editingCtx.getPointsCount()) {
|
||||
if (editingCtx.getAfterPoints().size() >= pos - editingCtx.getPointsCount()) {
|
||||
pt = editingCtx.getAfterPoints().get(pos - editingCtx.getPointsCount());
|
||||
} else {
|
||||
pos = editingCtx.getPointsCount() - 1;
|
||||
pt = editingCtx.getPoints().get(pos);
|
||||
}
|
||||
} else if (pos < 0) {
|
||||
pos = 0;
|
||||
pt = editingCtx.getPoints().get(pos);
|
||||
}
|
||||
if (pt == null) {
|
||||
pt = editingCtx.getPoints().get(pos);
|
||||
}
|
||||
moveMapToLatLon(pt.getLatitude(), pt.getLongitude());
|
||||
}
|
||||
}
|
||||
public void moveMapToPoint(int pos) {
|
||||
if (editingCtx.getPointsCount() > 0) {
|
||||
if (pos >= editingCtx.getPointsCount()) {
|
||||
pos = editingCtx.getPointsCount() - 1;
|
||||
} else if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
WptPt pt = editingCtx.getPoints().get(pos);
|
||||
moveMapToLatLon(pt.getLatitude(), pt.getLongitude());
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshMap() {
|
||||
view.refreshMap();
|
||||
|
|
Loading…
Reference in a new issue