diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 0bffe82f0f..fac22a103d 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -32,6 +32,7 @@ public class RasterMapMenu { OsmandApplication app = mapActivity.getMyApplication(); final OsmandSettings settings = app.getSettings(); final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class); + assert plugin != null; final OsmandSettings.CommonPreference mapTransparencyPreference; final OsmandSettings.CommonPreference mapTypePreference; @StringRes final int mapTypeString; @@ -102,26 +103,28 @@ public class RasterMapMenu { int selectedCode = selected ? 1 : 0; mapTypeDescr = selected ? mapTypeDescr : mapActivity.getString(R.string.shared_string_none); contextMenuAdapter.item(toggleActionStringId).listen(l).selected(selectedCode).reg(); - contextMenuAdapter.item(mapTypeString).listen(l).layout(R.layout.two_line_list_item) - .description(mapTypeDescr).reg(); - ContextMenuAdapter.OnIntegerValueChangedListener integerListener = - new ContextMenuAdapter.OnIntegerValueChangedListener() { - @Override - public boolean onIntegerValueChangedListener(int newValue) { - mapTransparencyPreference.set(newValue); - mapActivity.getMapView().refreshMap(); - return false; - } - }; - // android:max="255" in layout is expected - contextMenuAdapter.item(mapTypeStringTransparency) - .layout(R.layout.progress_list_item) - .iconColor(R.drawable.ic_action_opacity) - .progress(mapTransparencyPreference.get()) - .listenInteger(integerListener).reg(); - if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) { - contextMenuAdapter.item(R.string.show_polygons).listen(l) - .selected(hidePolygonsPref.get() ? 0 : 1).reg(); + if (selected) { + contextMenuAdapter.item(mapTypeString).listen(l).layout(R.layout.two_line_list_item) + .description(mapTypeDescr).reg(); + ContextMenuAdapter.OnIntegerValueChangedListener integerListener = + new ContextMenuAdapter.OnIntegerValueChangedListener() { + @Override + public boolean onIntegerValueChangedListener(int newValue) { + mapTransparencyPreference.set(newValue); + mapActivity.getMapView().refreshMap(); + return false; + } + }; + // android:max="255" in layout is expected + contextMenuAdapter.item(mapTypeStringTransparency) + .layout(R.layout.progress_list_item) + .iconColor(R.drawable.ic_action_opacity) + .progress(mapTransparencyPreference.get()) + .listenInteger(integerListener).reg(); + if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) { + contextMenuAdapter.item(R.string.show_polygons).listen(l) + .selected(hidePolygonsPref.get() ? 0 : 1).reg(); + } } }