Issue #6524 - Quick Action crash after selecting empty Overlay/Underlay/Map Style actions - FIXED

This commit is contained in:
madwasp79 2019-02-19 14:10:18 +02:00
parent d9bf5ca746
commit bb477d3272
3 changed files with 45 additions and 44 deletions

View file

@ -84,23 +84,25 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
OsmandSettings settings = activity.getMyApplication().getSettings(); OsmandSettings settings = activity.getMyApplication().getSettings();
List<Pair<String, String>> sources = loadListFromParams(); List<Pair<String, String>> sources = loadListFromParams();
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); if(sources.size()>0) {
if (showBottomSheetStyles) { boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
showChooseDialog(activity.getSupportFragmentManager()); if (showBottomSheetStyles) {
return; showChooseDialog(activity.getSupportFragmentManager());
} return;
}
Pair<String, String> currentSource = new Pair<>(
settings.MAP_OVERLAY.get(),
settings.MAP_OVERLAY.get());
Pair<String, String> nextSource = sources.get(0); Pair<String, String> currentSource = new Pair<>(
int index = sources.indexOf(currentSource); settings.MAP_OVERLAY.get(),
settings.MAP_OVERLAY.get());
if (index >= 0 && index + 1 < sources.size()) { Pair<String, String> nextSource = sources.get(0);
nextSource = sources.get(index + 1); int index = sources.indexOf(currentSource);
if (index >= 0 && index + 1 < sources.size()) {
nextSource = sources.get(index + 1);
}
executeWithParams(activity, nextSource.first);
} }
executeWithParams(activity, nextSource.first);
} }
} }
@ -193,8 +195,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
@Override @Override
public boolean fillParams(View root, MapActivity activity) { public boolean fillParams(View root, MapActivity activity) {
super.fillParams(root, activity);
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return true; return super.fillParams(root, activity);
} }
} }

View file

@ -77,24 +77,25 @@ public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
OsmandSettings settings = activity.getMyApplication().getSettings(); OsmandSettings settings = activity.getMyApplication().getSettings();
List<Pair<String, String>> sources = loadListFromParams(); List<Pair<String, String>> sources = loadListFromParams();
if(sources.size()>0) {
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
if (showBottomSheetStyles) {
showChooseDialog(activity.getSupportFragmentManager());
return;
}
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); Pair<String, String> currentSource = settings.MAP_ONLINE_DATA.get()
if (showBottomSheetStyles) {
showChooseDialog(activity.getSupportFragmentManager());
return;
}
Pair<String, String> currentSource = settings.MAP_ONLINE_DATA.get()
? new Pair<>(settings.MAP_TILE_SOURCES.get(), settings.MAP_TILE_SOURCES.get()) ? new Pair<>(settings.MAP_TILE_SOURCES.get(), settings.MAP_TILE_SOURCES.get())
: new Pair<>(LAYER_OSM_VECTOR, activity.getString(R.string.vector_data)); : new Pair<>(LAYER_OSM_VECTOR, activity.getString(R.string.vector_data));
Pair<String, String> nextSource = sources.get(0); Pair<String, String> nextSource = sources.get(0);
int index = sources.indexOf(currentSource); int index = sources.indexOf(currentSource);
if (index >= 0 && index + 1 < sources.size()) { if (index >= 0 && index + 1 < sources.size()) {
nextSource = sources.get(index + 1); nextSource = sources.get(index + 1);
}
executeWithParams(activity, nextSource.first);
} }
executeWithParams(activity, nextSource.first);
} }
} }
@ -195,8 +196,7 @@ public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
@Override @Override
public boolean fillParams(View root, MapActivity activity) { public boolean fillParams(View root, MapActivity activity) {
super.fillParams(root, activity);
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return true; return super.fillParams(root, activity);
} }
} }

View file

@ -82,24 +82,25 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
OsmandSettings settings = activity.getMyApplication().getSettings(); OsmandSettings settings = activity.getMyApplication().getSettings();
List<Pair<String, String>> sources = loadListFromParams(); List<Pair<String, String>> sources = loadListFromParams();
if(sources.size()>0) {
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
if (showBottomSheetStyles) {
showChooseDialog(activity.getSupportFragmentManager());
return;
}
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); Pair<String, String> currentSource = new Pair<>(
if (showBottomSheetStyles) {
showChooseDialog(activity.getSupportFragmentManager());
return;
}
Pair<String, String> currentSource = new Pair<>(
settings.MAP_UNDERLAY.get(), settings.MAP_UNDERLAY.get(),
settings.MAP_UNDERLAY.get()); settings.MAP_UNDERLAY.get());
Pair<String, String> nextSource = sources.get(0); Pair<String, String> nextSource = sources.get(0);
int index = sources.indexOf(currentSource); int index = sources.indexOf(currentSource);
if (index >= 0 && index + 1 < sources.size()) { if (index >= 0 && index + 1 < sources.size()) {
nextSource = sources.get(index + 1); nextSource = sources.get(index + 1);
}
executeWithParams(activity, nextSource.first);
} }
executeWithParams(activity, nextSource.first);
} }
} }
@ -196,8 +197,7 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
@Override @Override
public boolean fillParams(View root, MapActivity activity) { public boolean fillParams(View root, MapActivity activity) {
super.fillParams(root, activity);
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return true; return super.fillParams(root, activity);
} }
} }