MapViewModel

class MapViewModel @Inject constructor(savedStateHandle: SavedStateHandle, repository: EditTrackRepository, addWaypointUseCase: AddWaypointUseCase, clearAllUseCase: ClearAllUseCase, getTrackWaypointsUseCase: GetTrackWaypointsUseCase, displayTrackUseCase: DisplayTrackUseCase, exportTrackUseCase: ExportTrackUseCase, trackImportUseCase: TrackImportUseCase, addWaypointToSelectedTrackUseCase: AddWaypointToSelectedTrackUseCase, handleMapViewportChangeUseCase: HandleMapViewportChangeUseCase, updateSelectionUseCase: UpdateSelectionUseCase, stringProvider: StringProvider, hapticFeedback: HapticFeedback, filterTool: FilterTool, joinTool: JoinTool, deleteTool: DeleteTool, exportTool: ExportTool, reverseTool: ReverseTool, context: Context) : ViewModel

Constructors

Link copied to clipboard
@Inject
constructor(savedStateHandle: SavedStateHandle, repository: EditTrackRepository, addWaypointUseCase: AddWaypointUseCase, clearAllUseCase: ClearAllUseCase, getTrackWaypointsUseCase: GetTrackWaypointsUseCase, displayTrackUseCase: DisplayTrackUseCase, exportTrackUseCase: ExportTrackUseCase, trackImportUseCase: TrackImportUseCase, addWaypointToSelectedTrackUseCase: AddWaypointToSelectedTrackUseCase, handleMapViewportChangeUseCase: HandleMapViewportChangeUseCase, updateSelectionUseCase: UpdateSelectionUseCase, stringProvider: StringProvider, hapticFeedback: HapticFeedback, filterTool: FilterTool, joinTool: JoinTool, deleteTool: DeleteTool, exportTool: ExportTool, reverseTool: ReverseTool, context: Context)

Properties

Link copied to clipboard
Link copied to clipboard
val editState: StateFlow<EditState>
Link copied to clipboard
val exportResult: SharedFlow<Result<Uri>>
Link copied to clipboard
val progressState: StateFlow<ProgressData>
Link copied to clipboard
val showExportDialog: SharedFlow<String>
Link copied to clipboard
val toastEvents: MutableSharedFlow<String>
Link copied to clipboard

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
fun addWaypoint(lat: Double, lng: Double)

Add waypoint to selected track

Link copied to clipboard
fun clearAll()
Link copied to clipboard
Link copied to clipboard
fun importTrack(uri: Uri)
Link copied to clipboard
suspend fun loadTrackWaypoints(trackId: Int, center: Boolean)
Link copied to clipboard
suspend fun loadTrackWaypointsAndUpdate(trackId: Int, center: Boolean)

Reemit imported track to flow listened to by mapActivity

Link copied to clipboard
fun movePoint(waypointList: List<Waypoint>, pointIndex: Int?, pointId: Double?, isPointSet: Boolean = false)

Send coord to activity and to database if set

Link copied to clipboard
suspend fun onToolResult(tool: ActionType, result: Any?)

Called when tool finished processing

Link copied to clipboard
fun onToolSelected(action: ActionType, isSelected: Boolean = true)

Propagates selected tool to UI /!\ Update version, if same tool selected twice, wont trigger /!\

Link copied to clipboard
fun selectedTrack(trackId: Int?, select: Boolean, pointId: Double?): UiMapState
Link copied to clipboard
suspend fun sendDeleteResults(parameters: WaypointUpdate?)
Link copied to clipboard
suspend fun sendFilterResults(result: FilterResult)
Link copied to clipboard
suspend fun sendJoinResults(result: List<*>?)
Link copied to clipboard
fun singleTapConfirmed(geoPoint: GeoPoint)

Manage single tap

Link copied to clipboard
fun toolExport(fileName: String, format: ExportFormat)
Link copied to clipboard
fun viewChanged(latNorth: Double, latSouth: Double, lonWest: Double, lonEast: Double, zoom: Double)

When user moves map, recalculate what tracks should be displayed and with which algorithm