From 9cfd0f5e360b8faa5bc44b728ee3b6da17861cf5 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 25 Mar 2021 23:45:29 +0200 Subject: [PATCH 1/4] Directions: Displayed tracks, select segment doesn't show https://github.com/osmandapp/OsmAnd-Issues/issues/518 --- .../routepreparationmenu/cards/TracksCard.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index 5becff9bad..7170847059 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -10,6 +10,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; @@ -20,7 +21,11 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.routepreparationmenu.FollowTrackFragment; +import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.track.TrackMenuFragment; +import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import java.io.File; import java.util.ArrayList; @@ -30,7 +35,7 @@ import java.util.List; public class TracksCard extends BaseCard { - private List gpxFiles; + private final List gpxFiles; private boolean showLimited = true; private static class GpxItem { @@ -127,8 +132,13 @@ public class TracksCard extends BaseCard { app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false, true); } } - mapActivity.getMapActions().setGPXRouteParams(item.file); - app.getTargetPointsHelper().updateRouteAndRefresh(true); + if (item.file.getNonEmptySegmentsCount() > 1) { + Fragment f = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackMenuFragment.TAG); + TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); + } else { + mapActivity.getMapActions().setGPXRouteParams(item.file); + app.getTargetPointsHelper().updateRouteAndRefresh(true); + } } }); tracks.addView(v); From 8ee7cd0736ffbe0a916293db06915ea1820ab45d Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 25 Mar 2021 23:47:04 +0200 Subject: [PATCH 2/4] Remove unused import and unnecessary casting --- .../plus/routepreparationmenu/cards/TracksCard.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index 7170847059..1abccb3382 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -21,8 +21,6 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; -import net.osmand.plus.routepreparationmenu.FollowTrackFragment; -import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; @@ -81,7 +79,7 @@ public class TracksCard extends BaseCard { } }); - LinearLayout tracks = (LinearLayout) view.findViewById(R.id.items); + LinearLayout tracks = view.findViewById(R.id.items); tracks.removeAllViews(); int minCardHeight = app.getResources().getDimensionPixelSize(R.dimen.route_info_card_item_height); @@ -115,10 +113,10 @@ public class TracksCard extends BaseCard { ((TextView) v.findViewById(R.id.points_count)).setTextColor(descriptionColor); ((TextView) v.findViewById(R.id.time)).setTextColor(descriptionColor); - ImageView img = (ImageView) v.findViewById(R.id.icon); + ImageView img = v.findViewById(R.id.icon); img.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark)); img.setVisibility(View.VISIBLE); - LinearLayout container = (LinearLayout) v.findViewById(R.id.container); + LinearLayout container = v.findViewById(R.id.container); container.setMinimumHeight(minCardHeight); AndroidUtils.setPadding(container, listContentPadding, 0, 0, 0); v.setOnClickListener(new View.OnClickListener() { @@ -134,7 +132,7 @@ public class TracksCard extends BaseCard { } if (item.file.getNonEmptySegmentsCount() > 1) { Fragment f = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackMenuFragment.TAG); - TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); + TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); } else { mapActivity.getMapActions().setGPXRouteParams(item.file); app.getTargetPointsHelper().updateRouteAndRefresh(true); From 99c432d9ff37216b2e2dc367069fdd09d9a6e007 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Sun, 28 Mar 2021 23:41:49 +0300 Subject: [PATCH 3/4] Change targetFragment to MapRouteInfoMenu, static startNavigation --- .../MapRouteInfoMenuFragment.java | 47 ++++++++++++++----- .../cards/TracksCard.java | 6 +-- .../osmand/plus/track/TrackMenuFragment.java | 23 +++++---- 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index bd1d382677..8710c934dd 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -16,6 +16,7 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; +import net.osmand.GPXUtilities; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.plus.OsmandApplication; @@ -23,11 +24,14 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.routing.GPXRouteParams; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.track.TrackMenuFragment; +import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import net.osmand.plus.widgets.TextViewExProgress; -public class MapRouteInfoMenuFragment extends ContextMenuFragment { +public class MapRouteInfoMenuFragment extends ContextMenuFragment implements TrackSelectSegmentBottomSheet.OnSegmentSelectedListener { public static final String TAG = MapRouteInfoMenuFragment.class.getName(); @Nullable @@ -95,13 +99,13 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { MapActivity mapActivity = requireMapActivity(); menu = mapActivity.getMapRouteInfoMenu(); View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { - bottomContainer = (FrameLayout) view.findViewById(R.id.bottom_container); + bottomContainer = view.findViewById(R.id.bottom_container); modesLayoutToolbar = view.findViewById(R.id.modes_layout_toolbar); modesLayoutToolbarContainer = view.findViewById(R.id.modes_layout_toolbar_container); modesLayoutListContainer = view.findViewById(R.id.modes_layout_list_container); @@ -121,7 +125,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { int widthNoShadow = getLandscapeNoShadowWidth(); modesLayoutToolbar.setLayoutParams(new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT)); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT); - params.gravity = Gravity.BOTTOM|Gravity.START; + params.gravity = Gravity.BOTTOM | Gravity.START; view.findViewById(R.id.control_buttons).setLayoutParams(params); View appModesView = view.findViewById(R.id.app_modes); AndroidUtils.setPadding(appModesView, 0, 0, appModesView.getPaddingRight(), 0); @@ -182,15 +186,15 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { @Override protected void updateMenuState(int currentMenuState, int newMenuState) { - if(getMyApplication().getRoutingHelper().isRouteCalculated() ) { + if (getMyApplication().getRoutingHelper().isRouteCalculated()) { ApplicationMode mV = getMyApplication().getRoutingHelper().getAppMode(); if (newMenuState == MenuState.HEADER_ONLY && currentMenuState == MenuState.HALF_SCREEN) { - getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.setModeValue(mV,true); + getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.setModeValue(mV, true); } else if (currentMenuState == MenuState.HEADER_ONLY && newMenuState == MenuState.HALF_SCREEN) { getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.resetModeToDefault(mV); } } - } + } @Override protected void setViewY(int y, boolean animated, boolean adjustMapPos) { @@ -347,7 +351,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { OsmandApplication app = getMyApplication(); return app != null && app.getRoutingHelper().isOsmandRouting(); } - + public void updateRouteCalculationProgress(int progress) { MapActivity mapActivity = getMapActivity(); View mainView = getMainView(); @@ -356,7 +360,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { return; } boolean indeterminate = isPublicTransportMode() || !isOsmandRouting(); - ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar); + ProgressBar progressBar = mainView.findViewById(R.id.progress_bar); if (progressBar != null) { if (progress == 0) { progressBar.setIndeterminate(indeterminate); @@ -366,14 +370,14 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { } progressBar.setProgress(progress); } - ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button); + ProgressBar progressBarButton = view.findViewById(R.id.progress_bar_button); if (progressBarButton != null) { if (progressBarButton.getVisibility() != View.VISIBLE) { progressBarButton.setVisibility(View.VISIBLE); } progressBarButton.setProgress(indeterminate ? 0 : progress); } - TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr); + TextViewExProgress textViewExProgress = view.findViewById(R.id.start_button_descr); textViewExProgress.percent = indeterminate ? 0 : progress / 100f; textViewExProgress.invalidate(); } @@ -390,11 +394,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { if (progressBar != null) { progressBar.setVisibility(View.GONE); } - ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button); + ProgressBar progressBarButton = view.findViewById(R.id.progress_bar_button); if (progressBarButton != null) { progressBarButton.setProgress(0); } - TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr); + TextViewExProgress textViewExProgress = view.findViewById(R.id.start_button_descr); textViewExProgress.percent = 0; } @@ -501,4 +505,21 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { return false; } } + + @Override + public void onSegmentSelect(GPXUtilities.GPXFile gpxFile, int selectedSegment) { + if (getMyApplication() != null) { + getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + TrackMenuFragment.startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); + GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute(); + if (paramsBuilder != null) { + paramsBuilder.setSelectedSegment(selectedSegment); + getMyApplication().getRoutingHelper().onSettingsChanged(true); + } + dismiss(); + } + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index 1abccb3382..fe09174683 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -21,8 +21,8 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import java.io.File; @@ -131,8 +131,8 @@ public class TracksCard extends BaseCard { } } if (item.file.getNonEmptySegmentsCount() > 1) { - Fragment f = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackMenuFragment.TAG); - TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); + Fragment targetFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(MapRouteInfoMenuFragment.TAG); + TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, targetFragment); } else { mapActivity.getMapActions().setGPXRouteParams(item.file); app.getTargetPointsHelper().updateRouteAndRefresh(true); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index bb738a8e00..f5c52a11ce 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -82,8 +82,8 @@ import net.osmand.plus.myplaces.TrackActivityFragmentAdapter; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; -import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; @@ -804,7 +804,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (gpxFile.getNonEmptySegmentsCount() > 1) { TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), gpxFile, this); } else { - startNavigationForGPX(gpxFile, mapActions); + startNavigationForGPX(gpxFile, mapActions, mapActivity); dismiss(); } } @@ -827,7 +827,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card segment = segments.get(0); } } - GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}; + GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}; List items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); if (segment != null && !Algorithms.isEmpty(items)) { SplitSegmentDialogFragment.showInstance(fragmentManager, displayHelper, items.get(0), segment); @@ -904,12 +904,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - private void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions) { - if (app.getRoutingHelper().isFollowingMode()) { + public static void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions, final MapActivity mapActivity) { + if (mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) { mapActions.stopNavigationActionConfirm(null, new Runnable() { @Override public void run() { - MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null, null, null, true, true, MenuState.HEADER_ONLY); @@ -1130,7 +1129,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.action_edit) { - editSegment(segment); + editSegment(); return true; } else if (i == R.id.action_delete) { FragmentActivity activity = getActivity(); @@ -1164,7 +1163,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - startNavigationForGPX(gpxFile, mapActivity.getMapActions()); + startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); if (paramsBuilder != null) { paramsBuilder.setSelectedSegment(selectedSegment); @@ -1174,7 +1173,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - private void editSegment(TrkSegment segment) { + private void editSegment() { GPXFile gpxFile = getGpx(); openPlanRoute(new GpxData(gpxFile)); hide(); @@ -1219,7 +1218,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void gpxSavingFinished(Exception errorMessage) { if (selectedGpxFile != null) { - List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}); + List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}); selectedGpxFile.setDisplayGroups(groups, app); selectedGpxFile.processPoints(app); } @@ -1313,7 +1312,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } public static void showInstance(@NonNull MapActivity mapActivity, - @Nullable String path, + @Nullable String path, boolean showCurrentTrack, @Nullable final LatLon latLon, @Nullable final String returnScreenName, @@ -1332,7 +1331,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } public static boolean showInstance(@NonNull MapActivity mapActivity, - @NonNull SelectedGpxFile selectedGpxFile, + @NonNull SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon, @Nullable String returnScreenName, @Nullable String callingFragmentTag) { From 03a450f9e2bfd72303831f4ee9129ada47defc3e Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 29 Mar 2021 12:49:11 +0300 Subject: [PATCH 4/4] WeakReference - mapActivity, import header --- .../MapRouteInfoMenuFragment.java | 22 +++++++++---------- .../osmand/plus/track/TrackMenuFragment.java | 6 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index 8710c934dd..b60074f0b4 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -31,6 +31,8 @@ import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import net.osmand.plus.widgets.TextViewExProgress; +import static net.osmand.plus.track.TrackMenuFragment.startNavigationForGPX; + public class MapRouteInfoMenuFragment extends ContextMenuFragment implements TrackSelectSegmentBottomSheet.OnSegmentSelectedListener { public static final String TAG = MapRouteInfoMenuFragment.class.getName(); @@ -508,18 +510,16 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment implements Tra @Override public void onSegmentSelect(GPXUtilities.GPXFile gpxFile, int selectedSegment) { - if (getMyApplication() != null) { - getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - TrackMenuFragment.startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); - GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute(); - if (paramsBuilder != null) { - paramsBuilder.setSelectedSegment(selectedSegment); - getMyApplication().getRoutingHelper().onSettingsChanged(true); - } - dismiss(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); + startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); + GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute(); + if (paramsBuilder != null) { + paramsBuilder.setSelectedSegment(selectedSegment); + getMyApplication().getRoutingHelper().onSettingsChanged(true); } + dismiss(); } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index f5c52a11ce..b2d3aaa7dd 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -906,11 +906,13 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public static void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions, final MapActivity mapActivity) { if (mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) { + final WeakReference activityRef = new WeakReference<>(mapActivity); mapActions.stopNavigationActionConfirm(null, new Runnable() { @Override public void run() { - if (mapActivity != null) { - mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null, + MapActivity activity = activityRef.get(); + if (activity != null) { + activity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null, null, null, true, true, MenuState.HEADER_ONLY); } }