Merge branch 'sasha_pasha_branch' of ssh://github.com/osmandapp/Osmand into sasha_pasha_branch

This commit is contained in:
PavelRatushny 2017-10-11 16:17:34 +03:00
commit fc6453fcbf
2 changed files with 17 additions and 14 deletions

View file

@ -132,11 +132,7 @@ public class MarkersPlanRouteContext {
}
}
void recreateSnapTrkSegment() {
recreateSnapTrkSegment(true);
}
private void recreateSnapTrkSegment(boolean adjustMap) {
void recreateSnapTrkSegment(boolean adjustMap) {
snapTrkSegment.points.clear();
List<WptPt> points = getPointsToCalculate();
if (snappedMode == ApplicationMode.DEFAULT) {

View file

@ -285,7 +285,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged();
updateSelectButton();
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(false);
}
@Override
@ -308,7 +308,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
// to avoid crash because of:
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
}
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(false);
}
}
});
@ -408,13 +408,17 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
@Override
public void onApplicationModeItemClick(ApplicationMode mode) {
if (planRouteContext.getSnappedMode() != mode) {
boolean defaultMode = mode == ApplicationMode.DEFAULT;
MapMarkersLayer layer = getMapMarkersLayer();
if (layer != null) {
layer.setDefaultAppMode(mode == ApplicationMode.DEFAULT);
layer.setDefaultAppMode(defaultMode);
}
if (defaultMode) {
planRouteContext.cancelSnapToRoad();
}
planRouteContext.getSnappedToRoadPoints().clear();
planRouteContext.setSnappedMode(mode);
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(false);
setupAppModesBtn();
}
}
@ -485,7 +489,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
if (mapActivity != null) {
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
settings.ROUTE_MAP_MARKERS_ROUND_TRIP.set(!settings.ROUTE_MAP_MARKERS_ROUND_TRIP.get());
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(false);
}
}
@ -507,13 +511,14 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
markersHelper.reverseActiveMarkersOrder();
adapter.reloadData();
adapter.notifyDataSetChanged();
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(false);
}
}
};
}
private void selectAllOnClick() {
boolean adjustMap = false;
int activeMarkersCount = markersHelper.getMapMarkers().size();
if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
markersHelper.deselectAllActiveMarkers();
@ -523,10 +528,11 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
markersHelper.selectAllActiveMarkers();
markersHelper.setStartFromMyLocation(true);
selectedCount = activeMarkersCount;
adjustMap = true;
}
adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged();
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(adjustMap);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.refreshMap();
@ -580,7 +586,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
}
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(true);
mapActivity.refreshMap();
updateSelectButton();
}
@ -729,6 +735,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(planRouteContext.getSnapTrkSegment());
mapActivity.refreshMap();
if (adjustMap) {
showRouteOnMap(planRouteContext.getSnapTrkSegment().points);
}
@ -866,7 +873,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
adapter.reloadData();
adapter.notifyDataSetChanged();
planRouteContext.recreateSnapTrkSegment();
planRouteContext.recreateSnapTrkSegment(false);
}
}.execute();
}