From 347b28dd31fbb6ff452bef0b071febdafdb2f125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=E4=80=80my=20Zehnder?= Date: Mon, 3 Apr 2017 04:02:08 +0200 Subject: [PATCH] Fixes #3617. When showing the elevation details, we need to distinguish between the user arriving by the dashboard or the route info menu. Only in the latter case the menu needs to be closed. --- .../ShowRouteInfoDialogFragment.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index b452c6384d..1d4a906818 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -386,24 +386,30 @@ public class ShowRouteInfoDialogFragment extends DialogFragment { final MapActivity activity = (MapActivity)getActivity(); if (activity != null) { dismiss(); + + final OsmandSettings settings = activity.getMyApplication().getSettings(); + settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), + settings.getLastKnownMapZoom(), + new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), + false, + gpxItem); + final MapRouteInfoMenu mapRouteInfoMenu = activity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); - final LatLon fLocation = location; - mapRouteInfoMenu.setOnDismissListener(new OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - mapRouteInfoMenu.setOnDismissListener(null); - - final OsmandSettings settings = activity.getMyApplication().getSettings(); - settings.setMapLocationToShow(fLocation.getLatitude(), fLocation.getLongitude(), - settings.getLastKnownMapZoom(), - new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), - false, - gpxItem); - - MapActivity.launchMapActivityMoveToTop(activity); - } - }); - mapRouteInfoMenu.hide(); + if (mapRouteInfoMenu.isVisible()) { + // We arrived here by the route info menu. + // First, we close it and then show the details. + mapRouteInfoMenu.setOnDismissListener(new OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + mapRouteInfoMenu.setOnDismissListener(null); + MapActivity.launchMapActivityMoveToTop(activity); + } + }); + mapRouteInfoMenu.hide(); + } else { + // We arrived here by the dashboard. + MapActivity.launchMapActivityMoveToTop(activity); + } } } }