Hiding controls when map layer disabled

This commit is contained in:
GaidamakUA 2016-02-23 11:06:31 +02:00
parent 5b40432d72
commit dc4ca416fa

View file

@ -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<Integer> mapTransparencyPreference;
final OsmandSettings.CommonPreference<String> 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();
}
}
}