From 38e560a7824b07ec00299b551c219c7574cdfa00 Mon Sep 17 00:00:00 2001 From: Shobhit Agarwal Date: Fri, 12 Jan 2024 00:31:24 +0530 Subject: [PATCH] Save map camera position for all screens (#2175) --- .../com/google/android/ground/ui/common/BaseMapViewModel.kt | 1 + .../ui/home/mapcontainer/HomeScreenMapContainerViewModel.kt | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt b/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt index fd6db63c16..386a6d8ab8 100644 --- a/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt +++ b/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt @@ -252,6 +252,7 @@ constructor( Timber.d("Camera moved : ${newCameraPosition.target}") lastCameraPosition = currentCameraPosition.value currentCameraPosition.value = newCameraPosition + mapStateRepository.setCameraPosition(newCameraPosition) } companion object { diff --git a/ground/src/main/java/com/google/android/ground/ui/home/mapcontainer/HomeScreenMapContainerViewModel.kt b/ground/src/main/java/com/google/android/ground/ui/home/mapcontainer/HomeScreenMapContainerViewModel.kt index fc90e6439a..c63db6c16e 100644 --- a/ground/src/main/java/com/google/android/ground/ui/home/mapcontainer/HomeScreenMapContainerViewModel.kt +++ b/ground/src/main/java/com/google/android/ground/ui/home/mapcontainer/HomeScreenMapContainerViewModel.kt @@ -53,7 +53,6 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch -import timber.log.Timber @OptIn(ExperimentalCoroutinesApi::class) @SharedViewModel @@ -61,7 +60,7 @@ class HomeScreenMapContainerViewModel @Inject internal constructor( private val loiRepository: LocationOfInterestRepository, - private val mapStateRepository: MapStateRepository, + mapStateRepository: MapStateRepository, private val submissionRepository: SubmissionRepository, locationManager: LocationManager, settingsManager: SettingsManager, @@ -152,9 +151,7 @@ internal constructor( override fun onMapCameraMoved(newCameraPosition: CameraPosition) { super.onMapCameraMoved(newCameraPosition) - Timber.d("Setting position to $newCameraPosition") onZoomChange(lastCameraPosition?.zoomLevel, newCameraPosition.zoomLevel) - mapStateRepository.setCameraPosition(newCameraPosition) } private fun onZoomChange(oldZoomLevel: Float?, newZoomLevel: Float?) {