Search in sources :

Example 91 with OsmandSettings

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();
    }
}
Also used : OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin) OsmandSettings(net.osmand.plus.OsmandSettings) Pair(android.support.v4.util.Pair)

Aggregations

OsmandSettings (net.osmand.plus.OsmandSettings)91 View (android.view.View)27 OsmandApplication (net.osmand.plus.OsmandApplication)25 ArrayList (java.util.ArrayList)20 LatLon (net.osmand.data.LatLon)17 DialogInterface (android.content.DialogInterface)14 ArrayAdapter (android.widget.ArrayAdapter)14 TextView (android.widget.TextView)14 AlertDialog (android.support.v7.app.AlertDialog)11 ImageView (android.widget.ImageView)11 PointDescription (net.osmand.data.PointDescription)10 AdapterView (android.widget.AdapterView)9 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)8 ContextMenuItem (net.osmand.plus.ContextMenuItem)8 ApplicationMode (net.osmand.plus.ApplicationMode)7 Paint (android.graphics.Paint)6 Pair (android.support.v4.util.Pair)6 ListView (android.widget.ListView)6 SpannableString (android.text.SpannableString)5 CompoundButton (android.widget.CompoundButton)5