Search in sources :

Example 1 with PredefinedProfilesGroup

use of net.osmand.plus.profiles.data.PredefinedProfilesGroup in project Osmand by osmandapp.

the class SelectNavProfileBottomSheet method savePredefinedEngine.

private void savePredefinedEngine(RoutingDataObject profile) {
    String stringKey = profile.getStringKey();
    OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
    ProfilesGroup profilesGroup = findGroupOfProfile(profile);
    if (profilesGroup != null) {
        PredefinedProfilesGroup group = (PredefinedProfilesGroup) profilesGroup;
        String type = group.getType().toUpperCase();
        OnlineRoutingEngine engine = EngineType.getTypeByName(type).newInstance(null);
        engine.put(EngineParameter.KEY, stringKey);
        engine.put(EngineParameter.VEHICLE_KEY, NONE_VEHICLE.getKey());
        engine.put(EngineParameter.CUSTOM_URL, profile.getDescription());
        String namePattern = getString(R.string.ltr_or_rtl_combine_via_dash);
        String name = String.format(namePattern, group.getTitle(), profile.getName());
        engine.put(EngineParameter.CUSTOM_NAME, name);
        helper.saveEngine(engine);
    }
}
Also used : PredefinedProfilesGroup(net.osmand.plus.profiles.data.PredefinedProfilesGroup) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) ProfilesGroup(net.osmand.plus.profiles.data.ProfilesGroup) PredefinedProfilesGroup(net.osmand.plus.profiles.data.PredefinedProfilesGroup)

Aggregations

OnlineRoutingHelper (net.osmand.plus.onlinerouting.OnlineRoutingHelper)1 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)1 PredefinedProfilesGroup (net.osmand.plus.profiles.data.PredefinedProfilesGroup)1 ProfilesGroup (net.osmand.plus.profiles.data.ProfilesGroup)1