Add variable to measurement context
This commit is contained in:
parent
50314a7709
commit
574d7a6c3a
2 changed files with 15 additions and 11 deletions
|
@ -36,6 +36,7 @@ public class MeasurementEditingContext {
|
||||||
private int selectedPointPosition = -1;
|
private int selectedPointPosition = -1;
|
||||||
private WptPt originalPointToMove;
|
private WptPt originalPointToMove;
|
||||||
|
|
||||||
|
private boolean inAddPointMode;
|
||||||
private boolean inSnapToRoadMode;
|
private boolean inSnapToRoadMode;
|
||||||
private boolean needUpdateCacheForSnap;
|
private boolean needUpdateCacheForSnap;
|
||||||
private int calculatedPairs;
|
private int calculatedPairs;
|
||||||
|
@ -53,6 +54,10 @@ public class MeasurementEditingContext {
|
||||||
return commandManager;
|
return commandManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isInAddPointMode() {
|
||||||
|
return inAddPointMode;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isInSnapToRoadMode() {
|
boolean isInSnapToRoadMode() {
|
||||||
return inSnapToRoadMode;
|
return inSnapToRoadMode;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +87,10 @@ public class MeasurementEditingContext {
|
||||||
this.originalPointToMove = originalPointToMove;
|
this.originalPointToMove = originalPointToMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setInAddPointMode(boolean inAddPointMode) {
|
||||||
|
this.inAddPointMode = inAddPointMode;
|
||||||
|
}
|
||||||
|
|
||||||
void setInSnapToRoadMode(boolean inSnapToRoadMode) {
|
void setInSnapToRoadMode(boolean inSnapToRoadMode) {
|
||||||
this.inSnapToRoadMode = inSnapToRoadMode;
|
this.inSnapToRoadMode = inSnapToRoadMode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,6 +609,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
public void addPointAfterOnClick() {
|
public void addPointAfterOnClick() {
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||||
|
editingCtx.setInAddPointMode(true);
|
||||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition() + 1);
|
editingCtx.splitSegments(editingCtx.getSelectedPointPosition() + 1);
|
||||||
}
|
}
|
||||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_after));
|
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_after));
|
||||||
|
@ -620,6 +621,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
public void addPointBeforeOnClick() {
|
public void addPointBeforeOnClick() {
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||||
|
editingCtx.setInAddPointMode(true);
|
||||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
||||||
}
|
}
|
||||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_before));
|
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_before));
|
||||||
|
@ -875,7 +877,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
private void cancelModes() {
|
private void cancelModes() {
|
||||||
if (editingCtx.getOriginalPointToMove() != null) {
|
if (editingCtx.getOriginalPointToMove() != null) {
|
||||||
cancelMovePointMode();
|
cancelMovePointMode();
|
||||||
} else if (!isSelectedPointMenuOpened() && editingCtx.getSelectedPointPosition() != -1) {
|
} else if (editingCtx.isInAddPointMode()) {
|
||||||
cancelAddPointBeforeOrAfterMode();
|
cancelAddPointBeforeOrAfterMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -900,6 +902,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
switchAddPointBeforeAfterMode(false);
|
switchAddPointBeforeAfterMode(false);
|
||||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
|
editingCtx.setInAddPointMode(false);
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
|
@ -911,6 +914,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
switchAddPointBeforeAfterMode(false);
|
switchAddPointBeforeAfterMode(false);
|
||||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
|
editingCtx.setInAddPointMode(false);
|
||||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
||||||
if (measurementToolLayer != null) {
|
if (measurementToolLayer != null) {
|
||||||
measurementToolLayer.refreshMap();
|
measurementToolLayer.refreshMap();
|
||||||
|
@ -1397,7 +1401,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
if (editingCtx.getOriginalPointToMove() != null) {
|
if (editingCtx.getOriginalPointToMove() != null) {
|
||||||
cancelMovePointMode();
|
cancelMovePointMode();
|
||||||
return;
|
return;
|
||||||
} else if (editingCtx.getSelectedPointPosition() != -1) {
|
} else if (editingCtx.isInAddPointMode()) {
|
||||||
cancelAddPointBeforeOrAfterMode();
|
cancelAddPointBeforeOrAfterMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1480,15 +1484,6 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSelectedPointMenuOpened() {
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(SelectedPointBottomSheetDialogFragment.TAG);
|
|
||||||
return fragment != null;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx) {
|
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx) {
|
||||||
try {
|
try {
|
||||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||||
|
|
Loading…
Reference in a new issue