From 259615ebde8270988c077e3d1321214ae53e10f3 Mon Sep 17 00:00:00 2001 From: crimean Date: Wed, 17 Jul 2019 19:19:14 +0300 Subject: [PATCH] Fix waypoint dialog back button --- .../plus/helpers/WaypointDialogHelper.java | 10 ++++++-- .../WaypointsFragment.java | 23 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index c1a05ac68d..fcc69cb443 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -378,7 +378,11 @@ public class WaypointDialogHelper { for (TargetPoint p : lt) { al.add(p.point); } - return new TspAnt().readGraph(al, start.point, end.point).solve(); + try { + return new TspAnt().readGraph(al, start.point, end.point).solve(); + } catch (Exception e) { + return null; + } } protected void onPostExecute(int[] result) { @@ -395,7 +399,9 @@ public class WaypointDialogHelper { dlg.dismiss(); } } - + if (result == null) { + return; + } List alocs = new ArrayList<>(); for (int i : result) { if (i > 0) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java index 477152f06b..9cee24f91e 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java @@ -330,6 +330,12 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS super.onSaveInstanceState(outState); } + @Override + public void onDestroyView() { + super.onDestroyView(); + onDismiss(); + } + @Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { @@ -909,6 +915,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS fragmentManager.beginTransaction() .add(R.id.routeMenuContainer, fragment, TAG) + .addToBackStack(TAG) .commitAllowingStateLoss(); return true; @@ -918,14 +925,24 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS } } + private void onDismiss() { + try { + if (useRouteInfoMenu) { + MapActivity mapActivity = (MapActivity) getActivity(); + if (mapActivity != null) { + mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(); + } + } + } catch (Exception e) { + // + } + } + private void dismiss() { try { MapActivity mapActivity = (MapActivity) getActivity(); if (mapActivity != null) { mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss(); - if (useRouteInfoMenu) { - mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(); - } } } catch (Exception e) { //