EvRoutePreferencesProvider

Provider of EV route preferences.

Implement this interface to supply EV route preferences from your application's settings or configuration. The preferences are used during route calculation to configure charging stop selection.

Example implementation:

class MyEvRoutePreferencesProvider(
private val settingsRepository: SettingsRepository
) : EvRoutePreferencesProvider {
override val preferences: StateFlow<EvRoutePreferences> = combineStates(
settingsRepository.preferredOperators,
settingsRepository.avoidedStations,
) { preferred, avoided ->
EvRoutePreferences.Builder()
.preferOperators(preferred)
.avoidStationIds(avoided)
.build()
}

override suspend fun setPreferOperators(operators: Set<String>): Boolean {
settingsRepository.setPreferOperators(operators)
return true
}

override suspend fun setAvoidOperators(operators: Set<String>) = false
}

Properties

Link copied to clipboard
abstract val preferences: StateFlow<EvRoutePreferences>

Returns a Flow that emits EvRoutePreferences whenever they change.

Functions

Link copied to clipboard
@MapboxExperimental
abstract suspend fun setAvoidOperators(operators: Set<String>): Boolean
Link copied to clipboard
@MapboxExperimental
abstract suspend fun setPreferOperators(operators: Set<String>): Boolean