DefaultPublicTransportBriefRouteViewModel

class DefaultPublicTransportBriefRouteViewModel(trafficRoute: TrafficRoute, val destinationTimeZone: TimeZone = TimeZone.getDefault(), scheduleProvider: PublicTransportScheduleProvider? = null, onCardClickCallback: () -> Unit = {}, onRouteActionClickCallback: () -> Unit = {}) : PublicTransportBriefRouteViewModel

Default implementation of PublicTransportBriefRouteViewModel.

Extracts route information from TrafficRoute and provides it in a format suitable for the brief route card UI.

Parameters

trafficRoute

The traffic route containing public transport information.

destinationTimeZone

Timezone of the destination point, used for displaying arrival time. Defaults to TimeZone.getDefault (device's current timezone). For cross-timezone routes, callers should provide the destination's timezone.

scheduleProvider

Optional provider for fetching schedule information. When provided, enables async schedule loading.

onCardClickCallback

Callback invoked when the route card is clicked.

onRouteActionClickCallback

Callback invoked when the route action button is clicked.

Constructors

constructor(trafficRoute: TrafficRoute, destinationTimeZone: TimeZone = TimeZone.getDefault(), scheduleProvider: PublicTransportScheduleProvider? = null, onCardClickCallback: () -> Unit = {}, onRouteActionClickCallback: () -> Unit = {})

Properties

Link copied to clipboard
open override val destinationTimeZone: TimeZone
Link copied to clipboard
open override val isExpanded: StateFlow<Boolean>

Current expansion state of the route card. When true, the card displays detailed information (e.g., full schedule, transfer details). When false, only brief summary is shown (e.g., total duration, arrival time, total fare).

Link copied to clipboard
open override val routeSegments: StateFlow<List<RouteSegment>>

Ordered list of route segments that together form the complete journey. Each element represents a contiguous part of the route between two points. The sequence follows chronological order from departure to arrival.

Link copied to clipboard
open override val scheduleGroups: StateFlow<List<ScheduleGroup>>

Schedule groups for the first public transport segment.

Link copied to clipboard
open override val totalDuration: Duration

Total travel duration from start to end of the route. Excludes waiting times and transfer times.

Link copied to clipboard
open override val totalFare: FareInfo?

Total fare for the entire journey. Includes both the amount and the currency for proper formatting.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun onCardClick()

Handles click on the route card body.

Link copied to clipboard
open override fun onRouteActionClick()

Handles click on the primary route action button (for example, "Go").

Link copied to clipboard
open override fun onRouteDetailsClick()

Handles click on the route details/info action.

Link copied to clipboard
open override fun setExpanded(value: Boolean)

Updates card expansion state.