diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java index f1be5a9fad..94811ff241 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java @@ -473,6 +473,10 @@ public class TrackDetailsMenu { } public void refreshChart(LineChart chart, boolean forceFit) { + refreshChart(chart, true, forceFit); + } + + public void refreshChart(LineChart chart, boolean fitTrackOnMap, boolean forceFit) { MapActivity mapActivity = getMapActivity(); GpxDisplayItem gpxItem = getGpxItem(); if (mapActivity == null || gpxItem == null) { @@ -529,7 +533,9 @@ public class TrackDetailsMenu { if (location != null) { mapActivity.refreshMap(); } - fitTrackOnMap(chart, location, forceFit); + if (fitTrackOnMap) { + fitTrackOnMap(chart, location, forceFit); + } } public boolean shouldShowXAxisPoints () { diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/GraphsCard.java b/OsmAnd/src/net/osmand/plus/measurementtool/GraphsCard.java index ef376f48fd..deb636420a 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/GraphsCard.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/GraphsCard.java @@ -311,7 +311,7 @@ public class GraphsCard extends BaseCard implements OnUpdateInfoListener { private void updateChartOnMap() { if (hasVisibleGraph()) { trackDetailsMenu.reset(); - refreshMapCallback.refreshMap(false); + refreshMapCallback.refreshMap(false, false); } } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java b/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java index 1bc763b165..32a1f6a654 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/graph/CustomGraphAdapter.java @@ -61,11 +61,14 @@ public class CustomGraphAdapter extends BaseGraphAdapter elems = getStatistics().elements; + List elems = getStatistics().elements; int i = h.getStackIndex(); if (i >= 0 && elems.size() > i) { selectedPropertyName = elems.get(i).getPropertyName(); updateLegend(); + } else if (LegendViewType.ONE_ELEMENT == legendViewType && elems.size() == 1) { + selectedPropertyName = elems.get(0).getPropertyName(); + updateLegend(); } } @@ -116,19 +119,20 @@ public class CustomGraphAdapter extends BaseGraphAdapter attributes = getSegmentsList(); + if (attributes == null) return; switch (legendViewType) { case ONE_ELEMENT: - for (RouteSegmentAttribute segment : getSegmentsList()) { - if (segment.getPropertyName().equals(selectedPropertyName)) { - attachLegend(Collections.singletonList(segment), null); + for (RouteSegmentAttribute attribute : attributes) { + if (attribute.getPropertyName().equals(selectedPropertyName)) { + attachLegend(Collections.singletonList(attribute), null); break; } } break; case ALL_AS_LIST: - attachLegend(getSegmentsList(), selectedPropertyName); + attachLegend(attributes, selectedPropertyName); break; } } @@ -137,7 +141,7 @@ public class CustomGraphAdapter extends BaseGraphAdapter