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) { for (TargetPoint p : lt) {
al.add(p.point); al.add(p.point);
} }
try {
return new TspAnt().readGraph(al, start.point, end.point).solve(); return new TspAnt().readGraph(al, start.point, end.point).solve();
} catch (Exception e) {
return null;
}
} }
protected void onPostExecute(int[] result) { protected void onPostExecute(int[] result) {
@ -395,7 +399,9 @@ public class WaypointDialogHelper {
dlg.dismiss(); dlg.dismiss();
} }
} }
if (result == null) {
return;
}
List<TargetPoint> alocs = new ArrayList<>(); List<TargetPoint> alocs = new ArrayList<>();
for (int i : result) { for (int i : result) {
if (i > 0) { if (i > 0) {

View file

@ -330,6 +330,12 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@Override
public void onDestroyView() {
super.onDestroyView();
onDismiss();
}
@Override @Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
@ -909,6 +915,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.add(R.id.routeMenuContainer, fragment, TAG) .add(R.id.routeMenuContainer, fragment, TAG)
.addToBackStack(TAG)
.commitAllowingStateLoss(); .commitAllowingStateLoss();
return true; 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() { private void dismiss() {
try { try {
MapActivity mapActivity = (MapActivity) getActivity(); MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss(); mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
if (useRouteInfoMenu) {
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog();
}
} }
} catch (Exception e) { } catch (Exception e) {
// //