Search in sources :

Example 1 with EngineParameter

use of net.osmand.plus.onlinerouting.EngineParameter in project Osmand by osmandapp.

the class OnlineRoutingEngineFragment method restoreState.

private void restoreState(@NonNull Bundle savedState) {
    editedEngineKey = savedState.getString(EngineParameter.KEY.name());
    initEngine = createInitStateEngine();
    String typeKey = savedState.getString(ENGINE_TYPE_KEY);
    OnlineRoutingEngine type = EngineType.getTypeByName(typeKey);
    Map<String, String> params = new HashMap<>();
    for (EngineParameter key : EngineParameter.values()) {
        String value = savedState.getString(key.name());
        if (value != null) {
            params.put(key.name(), value);
        }
    }
    engine = type.newInstance(params);
    customVehicleKey = savedState.getString(ENGINE_CUSTOM_VEHICLE_KEY);
    selectedLocation = ExampleLocation.valueOf(savedState.getString(EXAMPLE_LOCATION_KEY));
    appMode = ApplicationMode.valueOfStringKey(savedState.getString(APP_MODE_KEY), null);
}
Also used : OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) EngineParameter(net.osmand.plus.onlinerouting.EngineParameter) HashMap(java.util.HashMap)

Example 2 with EngineParameter

use of net.osmand.plus.onlinerouting.EngineParameter in project Osmand by osmandapp.

the class OnlineRoutingEngineFragment method saveState.

private void saveState(@NonNull Bundle outState) {
    outState.putString(ENGINE_TYPE_KEY, engine.getTypeName());
    for (EngineParameter key : EngineParameter.values()) {
        String value = engine.get(key);
        if (value != null) {
            outState.putString(key.name(), value);
        }
    }
    outState.putString(ENGINE_CUSTOM_VEHICLE_KEY, customVehicleKey);
    outState.putString(EXAMPLE_LOCATION_KEY, selectedLocation.name());
    outState.putString(APP_MODE_KEY, getAppMode().getStringKey());
    outState.putString(EDITED_ENGINE_KEY, editedEngineKey);
}
Also used : EngineParameter(net.osmand.plus.onlinerouting.EngineParameter)

Aggregations

EngineParameter (net.osmand.plus.onlinerouting.EngineParameter)2 HashMap (java.util.HashMap)1 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)1