From 47f580838db0185292c989fb448f2bcb6ab33dac Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Wed, 17 Aug 2022 19:02:40 +0200 Subject: 5842: fix real location never fix in A-P UI --- .../features/location/FakeLocationFragment.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/foundation/e/privacycentralapp/features') 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. + } } } } -- cgit v1.2.3