diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-18 00:29:31 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-18 00:29:31 -0600 |
commit | a394a0e2489324b5dabc9854104e88946efedded (patch) | |
tree | 25df1e3df313922a2c60ebc76d206250cacf2e67 | |
parent | dfcc5e9e82f12b76b47b228202383c7cdce9044f (diff) | |
download | etbsa-trackermap-mobile-a394a0e2489324b5dabc9854104e88946efedded.tar.gz etbsa-trackermap-mobile-a394a0e2489324b5dabc9854104e88946efedded.tar.bz2 etbsa-trackermap-mobile-a394a0e2489324b5dabc9854104e88946efedded.zip |
More improvements to zoom
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt | 8 | ||||
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt | 8 |
2 files changed, 13 insertions, 3 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt index ca59266..e64afd3 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/UnitMapFragment.kt @@ -93,6 +93,10 @@ class UnitMapFragment : Fragment() { binding.mapUnitCard.visibility = if (selectedUnit == null) View.GONE else View.VISIBLE + if (selectedUnit == null) { + unitsViewModel.clearCamera() + } + selectedUnit?.let { unit -> if (unit.position == null || unit.position?.latitude == null || unit.position?.longitude == null) { binding.mapUnitCard.visibility = View.GONE @@ -142,7 +146,9 @@ class UnitMapFragment : Fragment() { } unitsViewModel.camera.observe(viewLifecycleOwner) { camera -> - mapFragment.focusOn(camera.point.y, camera.point.x) + camera?.let { + mapFragment.focusOn(camera.point.y, camera.point.x) + } } } diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt index ee6fa98..cb30725 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsViewModel.kt @@ -40,7 +40,7 @@ class UnitsViewModel( private var _selectedUnit = MutableLiveData<UnitInformation?>() private var _mapLayerType = MutableLiveData<MapLayer.Type>() private var _geofences = MutableLiveData<Map<Int, Geofence>>() - private val _camera = MutableLiveData<Camera>() + private val _camera = MutableLiveData<Camera?>() val searchQuery: LiveData<String> get() = _searchQuery val unitsDisplayMode: LiveData<UnitsDisplayMode> get() = _unitsDisplayMode @@ -48,7 +48,7 @@ class UnitsViewModel( val selectedUnit: LiveData<UnitInformation?> get() = _selectedUnit val mapLayerType: LiveData<MapLayer.Type> get() = _mapLayerType val geofences: LiveData<Map<Int, Geofence>> get() = _geofences - val camera: LiveData<Camera> get() = _camera + val camera: LiveData<Camera?> get() = _camera init { Log.d("UnitsViewModel", "Initializing Units View Model") @@ -119,4 +119,8 @@ class UnitsViewModel( fun moveCamera(point: Camera) { _camera.postValue(point) } + + fun clearCamera() { + _camera.postValue(null) + } }
\ No newline at end of file |