use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class MapSourceAction method execute.
@Override
public void execute(MapActivity activity) {
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
OsmandSettings settings = activity.getMyApplication().getSettings();
List<Pair<String, String>> sources = loadListFromParams();
Pair<String, String> 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<String, String> nextSource = sources.get(0);
int index = sources.indexOf(currentSource);
if (index >= 0 && index + 1 < sources.size()) {
nextSource = sources.get(index + 1);
}
if (nextSource.first.equals(LAYER_OSM_VECTOR)) {
settings.MAP_ONLINE_DATA.set(false);
activity.getMapLayers().updateMapSource(activity.getMapView(), null);
} else {
settings.MAP_TILE_SOURCES.set(nextSource.first);
settings.MAP_ONLINE_DATA.set(true);
activity.getMapLayers().updateMapSource(activity.getMapView(), settings.MAP_TILE_SOURCES);
}
Toast.makeText(activity, activity.getString(R.string.quick_action_map_source_switch, nextSource.second), Toast.LENGTH_SHORT).show();
}
}
Aggregations