From c6a1f997baec3cda11bde6c9c0080bb904cfacca Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Mon, 3 Jun 2019 16:10:59 +0300 Subject: [PATCH] fix for #6884 --- OsmAnd/res/values/strings.xml | 1 + .../quickaction/actions/MapStyleAction.java | 33 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index fb8665a67a..a31252e772 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -3164,5 +3164,6 @@ Launch OsmAnd? Avoid cobblestone and sett Avoid cobblestone and sett + You need to add at least one Item to list in Quick Action\' Settings diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index 7d3baec077..d1270daac2 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import net.osmand.util.Algorithms; public class MapStyleAction extends SwitchableAction { @@ -42,21 +43,26 @@ public class MapStyleAction extends SwitchableAction { @Override public void execute(MapActivity activity) { - List mapStyles = getFilteredStyles(); - boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); - if (showBottomSheetStyles) { - showChooseDialog(activity.getSupportFragmentManager()); - return; - } - String curStyle = activity.getMyApplication().getSettings().RENDERER.get(); - int index = mapStyles.indexOf(curStyle); - String nextStyle = mapStyles.get(0); + if (!Algorithms.isEmpty(mapStyles)) { + boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG)); + if (showBottomSheetStyles) { + showChooseDialog(activity.getSupportFragmentManager()); + return; + } + String curStyle = activity.getMyApplication().getSettings().RENDERER.get(); + int index = mapStyles.indexOf(curStyle); + String nextStyle = mapStyles.get(0); - if (index >= 0 && index + 1 < mapStyles.size()) { - nextStyle = mapStyles.get(index + 1); + if (index >= 0 && index + 1 < mapStyles.size()) { + nextStyle = mapStyles.get(index + 1); + } + executeWithParams(activity, nextStyle); + } else { + Toast.makeText(activity, R.string.quick_action_need_to_add_item_to_list, + Toast.LENGTH_LONG).show(); } - executeWithParams(activity, nextStyle); + } @Override @@ -181,9 +187,8 @@ public class MapStyleAction 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); } @Override