diff options
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/features')
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt index d98cb5d..2e014e2 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt @@ -135,6 +135,15 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) bindClickListeners() render(viewModel.state.value) + viewLifecycleOwner.lifecycleScope.launch { + viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.singleEvents.collect { event -> + if (event is FakeLocationViewModel.SingleEvent.LocationUpdatedEvent) { + updateLocation(event.location, event.mode) + } + } + } + } } } @@ -156,9 +165,6 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) is FakeLocationViewModel.SingleEvent.ErrorEvent -> { displayToast(event.error) } - is FakeLocationViewModel.SingleEvent.LocationUpdatedEvent -> { - updateLocation(event.location, event.mode) - } is FakeLocationViewModel.SingleEvent.RequestLocationPermission -> { // TODO for standalone: rationale dialog locationPermissionRequest.launch(arrayOf( @@ -166,6 +172,9 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) Manifest.permission.ACCESS_COARSE_LOCATION )) } + is FakeLocationViewModel.SingleEvent.LocationUpdatedEvent -> { + // Nothing here, another collect linked to mapbox view. + } } } } |