use of net.osmand.plus.onlinerouting.VehicleType in project Osmand by osmandapp.
the class OnlineRoutingEngineFragment method setupVehicleTypes.
private void setupVehicleTypes() {
List<ChipItem> vehicleItems = new ArrayList<>();
for (VehicleType vehicle : engine.getAllowedVehicles()) {
String title = vehicle.getTitle(app);
ChipItem item = new ChipItem(title);
item.title = title;
item.tag = vehicle;
vehicleItems.add(item);
}
vehicleCard.setSelectionMenu(vehicleItems, engine.getSelectedVehicleType().getTitle(app), result -> {
VehicleType vehicle = (VehicleType) result.tag;
if (!Algorithms.objectEquals(engine.getSelectedVehicleType(), vehicle)) {
String vehicleKey = vehicle.equals(CUSTOM_VEHICLE) ? customVehicleKey : vehicle.getKey();
engine.put(EngineParameter.VEHICLE_KEY, vehicleKey);
generateUniqueNameIfNeeded();
updateCardViews(nameCard, vehicleCard, exampleCard);
return true;
}
return false;
});
}
use of net.osmand.plus.onlinerouting.VehicleType in project Osmand by osmandapp.
the class OnlineRoutingEngine method getSelectedVehicleName.
@Nullable
private String getSelectedVehicleName(@NonNull Context ctx) {
String key = get(EngineParameter.VEHICLE_KEY);
VehicleType vt = getVehicleTypeByKey(key);
if (!vt.equals(CUSTOM_VEHICLE)) {
return vt.getTitle(ctx);
}
return key != null ? Algorithms.capitalizeFirstLetter(key) : null;
}
Aggregations