mirror of
https://github.com/Pygmalion69/OpenTopoMapViewer.git
synced 2025-10-06 00:02:42 +02:00
Fix orientation sensor not starting on rotation toggle
This commit is contained in:
@@ -900,6 +900,13 @@ class MapFragment : Fragment(), LocationListener, PopupMenu.OnMenuItemClickListe
|
||||
//Log.d(TAG, "map rotation set to $mapRotation")
|
||||
mPrefs.edit().putBoolean(SettingsActivity.PREF_ROTATE, mapRotation).apply()
|
||||
if (mapRotation) {
|
||||
val lastLocation = mLocationViewModel?.currentLocation?.value
|
||||
if (lastLocation?.hasBearing() == true) {
|
||||
stopOrientationSensor()
|
||||
MapOrientation.setTargetMapOrientation(mMapView, lastLocation.bearing)
|
||||
} else {
|
||||
orientationSensor = orientationSensor ?: OrientationSensor(requireContext(), mMapView)
|
||||
}
|
||||
Toast.makeText(requireContext(), R.string.rotation_on, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
stopOrientationSensor()
|
||||
|
Reference in New Issue
Block a user