Merge pull request #10349 from osmandapp/FixPlanRouteMapJumps

Fix plan route map jumps
This commit is contained in:
Vitaliy 2020-12-07 12:02:12 +00:00 committed by GitHub
commit c413626490
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 15 deletions

View file

@ -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 () {

View file

@ -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);
}
}

View file

@ -61,11 +61,14 @@ public class CustomGraphAdapter extends BaseGraphAdapter<HorizontalBarChart, Bar
public void onValueSelected(Entry e, Highlight h) {
if (getStatistics() == null) return;
List<RouteStatisticsHelper.RouteSegmentAttribute> elems = getStatistics().elements;
List<RouteSegmentAttribute> 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<HorizontalBarChart, Bar
}
private void attachLegend() {
if (getSegmentsList() == null) return;
List<RouteSegmentAttribute> 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<HorizontalBarChart, Bar
String propertyNameToFullSpan) {
OsmandApplication app = getMyApplication();
LayoutInflater inflater = LayoutInflater.from(app);
for (RouteStatisticsHelper.RouteSegmentAttribute segment : list) {
for (RouteSegmentAttribute segment : list) {
View view = inflater.inflate(R.layout.route_details_legend, legendContainer, false);
int segmentColor = segment.getColor();
Drawable circle = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, segmentColor);

View file

@ -105,11 +105,11 @@ public class GraphAdapterHelper {
@NonNull final TrackDetailsMenu detailsMenu) {
final RefreshMapCallback refreshMapCallback = new RefreshMapCallback() {
@Override
public void refreshMap(boolean forceFit) {
public void refreshMap(boolean fitTrackOnMap, boolean forceFit) {
LineChart chart = graphAdapter.getChart();
OsmandApplication app = mapActivity.getMyApplication();
if (!app.getRoutingHelper().isFollowingMode()) {
detailsMenu.refreshChart(chart, forceFit);
detailsMenu.refreshChart(chart, fitTrackOnMap, forceFit);
mapActivity.refreshMap();
}
}
@ -120,7 +120,7 @@ public class GraphAdapterHelper {
@Override
public void onValueSelected(Entry e, Highlight h) {
refreshMapCallback.refreshMap(false);
refreshMapCallback.refreshMap(true, false);
}
@Override
@ -141,7 +141,7 @@ public class GraphAdapterHelper {
lastPerformedGesture == ChartTouchListener.ChartGesture.PINCH_ZOOM ||
lastPerformedGesture == ChartTouchListener.ChartGesture.DOUBLE_TAP ||
lastPerformedGesture == ChartTouchListener.ChartGesture.ROTATE) {
refreshMapCallback.refreshMap(true);
refreshMapCallback.refreshMap(true, true);
}
}
});
@ -150,6 +150,6 @@ public class GraphAdapterHelper {
}
public interface RefreshMapCallback {
void refreshMap(boolean forceFit);
void refreshMap(boolean fitTrackOnMap, boolean forceFit);
}
}

View file

@ -369,7 +369,7 @@ public class RouteDetailsFragment extends ContextMenuFragment
super.calculateLayout(view, initLayout);
if (!initLayout && getCurrentMenuState() != MenuState.FULL_SCREEN) {
if (refreshMapCallback != null) {
refreshMapCallback.refreshMap(false);
refreshMapCallback.refreshMap(false, false);
}
}
}