Fix adding points before or after and move
This commit is contained in:
parent
f18de8935a
commit
c648dd2d3f
2 changed files with 16 additions and 34 deletions
|
@ -129,12 +129,8 @@ public class MeasurementEditingContext {
|
|||
points.addAll(after.points);
|
||||
before.points.clear();
|
||||
after.points.clear();
|
||||
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()));
|
||||
}
|
||||
before.points.addAll(points.subList(0, position));
|
||||
after.points.addAll(points.subList(position, points.size()));
|
||||
updateCacheForSnapIfNeeded(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -257,14 +257,14 @@ public class MeasurementToolFragment extends Fragment {
|
|||
mainView.findViewById(R.id.apply_point_before_after_point_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
applyAddPointBeforeOrAfterMode();
|
||||
applyAddPointBeforeAfterMode();
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.add_point_before_after_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
addPointBeforeOrAfter();
|
||||
addPointBeforeAfter();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -606,8 +606,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void addPointAfterOnClick() {
|
||||
if (measurementLayer != null) {
|
||||
editingCtx.setSelectedPointPosition(editingCtx.getSelectedPointPosition() + 1);
|
||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition() + 1);
|
||||
measurementLayer.enterAddingPointBeforeAfterMode();
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_after));
|
||||
|
@ -858,18 +857,24 @@ public class MeasurementToolFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void addPointBeforeOrAfter() {
|
||||
private void addPointBeforeAfter() {
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
if (addPointToPosition(editingCtx.getPointsCount())) {
|
||||
editingCtx.setSelectedPointPosition(editingCtx.getPointsCount());
|
||||
int selectedPoint = editingCtx.getSelectedPointPosition(); //after = 1; before = 1;
|
||||
int pointsCount = editingCtx.getPointsCount(); //after = 2; before = 1;
|
||||
if (addPointToPosition(editingCtx.getPointsCount())) { //выбрать вторую точку
|
||||
if (selectedPoint == pointsCount) {
|
||||
editingCtx.splitSegments(editingCtx.getPointsCount() - 1);
|
||||
} else {
|
||||
editingCtx.setSelectedPointPosition(selectedPoint + 1);
|
||||
}
|
||||
measurementLayer.refreshMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyAddPointBeforeOrAfterMode() {
|
||||
switchAddPointAfterMode(false);
|
||||
private void applyAddPointBeforeAfterMode() {
|
||||
switchAddPointBeforeAfterMode(false);
|
||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
|
@ -908,25 +913,6 @@ public class MeasurementToolFragment extends Fragment {
|
|||
: R.drawable.ic_action_ruler));
|
||||
}
|
||||
|
||||
private void switchAddPointAfterMode(boolean enable) {
|
||||
if (enable) {
|
||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
|
||||
} else {
|
||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||
}
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.showTopToolbar(toolBarController);
|
||||
}
|
||||
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
||||
mark(enable ? View.VISIBLE : View.GONE,
|
||||
R.id.add_point_before_after_text,
|
||||
R.id.add_point_before_after_controls);
|
||||
mainIcon.setImageDrawable(getActiveIcon(enable
|
||||
? R.drawable.ic_action_addpoint_above
|
||||
: R.drawable.ic_action_ruler));
|
||||
}
|
||||
|
||||
private void switchAddPointBeforeAfterMode(boolean enable) {
|
||||
if (enable) {
|
||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
|
||||
|
|
Loading…
Reference in a new issue