Skip to main content

Camera State

Every time any camera property is changing UX Framework produces its new state. You may collect such information via Dash.controller.observeCameraState() flow.

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
Dash.controller
.observeCameraState()
.debounce(1000.milliseconds)
.collect(this) { cameraState ->
// do something with camera state
}



Dash.controller.observeRoutes()
.collect { /* RouteChangeEvent */ event ->
val activeNavRoute = event.routes.firstOrNull()
// Do something with active NavigationRoute
}
}
}
}
}

Be aware that camera state properties change often. It might be good to limit received calls with debounce() operator.

Was this page helpful?