Fix waypoint dialog back button

This commit is contained in:
crimean 2019-07-17 19:19:14 +03:00
parent e66615b32d
commit 259615ebde
2 changed files with 28 additions and 5 deletions

View file

@ -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<TargetPoint> alocs = new ArrayList<>();
for (int i : result) {
if (i > 0) {

View file

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