From bb477d32727444ddecd5f0af348138037528ad0d Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Tue, 19 Feb 2019 14:10:18 +0200 Subject: [PATCH] Issue #6524 - Quick Action crash after selecting empty Overlay/Underlay/Map Style actions - FIXED --- .../quickaction/actions/MapOverlayAction.java | 33 ++++++++++--------- .../quickaction/actions/MapSourceAction.java | 28 ++++++++-------- .../actions/MapUnderlayAction.java | 28 ++++++++-------- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java index b0ec9e3bd9..4028cf0ebd 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java @@ -84,23 +84,25 @@ public class MapOverlayAction extends SwitchableAction> { OsmandSettings settings = activity.getMyApplication().getSettings(); List> sources = loadListFromParams(); - boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); - if (showBottomSheetStyles) { - showChooseDialog(activity.getSupportFragmentManager()); - return; - } - - Pair currentSource = new Pair<>( - settings.MAP_OVERLAY.get(), - settings.MAP_OVERLAY.get()); + if(sources.size()>0) { + boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); + if (showBottomSheetStyles) { + showChooseDialog(activity.getSupportFragmentManager()); + return; + } - Pair nextSource = sources.get(0); - int index = sources.indexOf(currentSource); + Pair currentSource = new Pair<>( + settings.MAP_OVERLAY.get(), + settings.MAP_OVERLAY.get()); - if (index >= 0 && index + 1 < sources.size()) { - nextSource = sources.get(index + 1); + Pair nextSource = sources.get(0); + 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> { @Override public boolean fillParams(View root, MapActivity activity) { - super.fillParams(root, activity); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); - return true; + return super.fillParams(root, activity); } } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java index d791d9d074..069b022743 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java @@ -77,24 +77,25 @@ public class MapSourceAction extends SwitchableAction> { OsmandSettings settings = activity.getMyApplication().getSettings(); List> 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)); - if (showBottomSheetStyles) { - showChooseDialog(activity.getSupportFragmentManager()); - return; - } - - Pair currentSource = settings.MAP_ONLINE_DATA.get() + Pair currentSource = settings.MAP_ONLINE_DATA.get() ? new Pair<>(settings.MAP_TILE_SOURCES.get(), settings.MAP_TILE_SOURCES.get()) : new Pair<>(LAYER_OSM_VECTOR, activity.getString(R.string.vector_data)); - Pair nextSource = sources.get(0); - int index = sources.indexOf(currentSource); + Pair nextSource = sources.get(0); + int index = sources.indexOf(currentSource); - if (index >= 0 && index + 1 < sources.size()) { - nextSource = sources.get(index + 1); + if (index >= 0 && index + 1 < sources.size()) { + nextSource = sources.get(index + 1); + } + executeWithParams(activity, nextSource.first); } - executeWithParams(activity, nextSource.first); } } @@ -195,8 +196,7 @@ public class MapSourceAction extends SwitchableAction> { @Override public boolean fillParams(View root, MapActivity activity) { - super.fillParams(root, activity); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); - return true; + return super.fillParams(root, activity); } } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java index db2af27323..acaeb2f03c 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java @@ -82,24 +82,25 @@ public class MapUnderlayAction extends SwitchableAction> { OsmandSettings settings = activity.getMyApplication().getSettings(); List> 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)); - if (showBottomSheetStyles) { - showChooseDialog(activity.getSupportFragmentManager()); - return; - } - - Pair currentSource = new Pair<>( + Pair currentSource = new Pair<>( settings.MAP_UNDERLAY.get(), settings.MAP_UNDERLAY.get()); - Pair nextSource = sources.get(0); - int index = sources.indexOf(currentSource); + Pair nextSource = sources.get(0); + int index = sources.indexOf(currentSource); - if (index >= 0 && index + 1 < sources.size()) { - nextSource = sources.get(index + 1); + if (index >= 0 && index + 1 < sources.size()) { + nextSource = sources.get(index + 1); + } + executeWithParams(activity, nextSource.first); } - executeWithParams(activity, nextSource.first); } } @@ -196,8 +197,7 @@ public class MapUnderlayAction extends SwitchableAction> { @Override public boolean fillParams(View root, MapActivity activity) { - super.fillParams(root, activity); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); - return true; + return super.fillParams(root, activity); } }