Search in sources :

Example 1 with ProfilesGroup

use of net.osmand.plus.profiles.data.ProfilesGroup 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)

Example 2 with ProfilesGroup

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

the class SelectNavProfileBottomSheet method createProfilesList.

private void createProfilesList() {
    for (ProfilesGroup group : profileGroups) {
        List<ProfileDataObject> items = group.getProfiles();
        if (!Algorithms.isEmpty(items)) {
            addGroupHeader(group.getTitle(), group.getDescription(app, nightMode));
            for (ProfileDataObject item : items) {
                addProfileItem(item);
            }
            addDivider();
        }
    }
}
Also used : ProfileDataObject(net.osmand.plus.profiles.data.ProfileDataObject) ProfilesGroup(net.osmand.plus.profiles.data.ProfilesGroup) PredefinedProfilesGroup(net.osmand.plus.profiles.data.PredefinedProfilesGroup)

Aggregations

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