Skip to content

Commit 383a7aa

Browse files
committed
2 parents fc0fb84 + 9119111 commit 383a7aa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/main/java/org/nitri/opentopo/MapFragment.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,13 @@ class MapFragment : Fragment(), LocationListener, PopupMenu.OnMenuItemClickListe
900900
//Log.d(TAG, "map rotation set to $mapRotation")
901901
mPrefs.edit().putBoolean(SettingsActivity.PREF_ROTATE, mapRotation).apply()
902902
if (mapRotation) {
903+
val lastLocation = mLocationViewModel?.currentLocation?.value
904+
if (lastLocation?.hasBearing() == true) {
905+
stopOrientationSensor()
906+
MapOrientation.setTargetMapOrientation(mMapView, lastLocation.bearing)
907+
} else {
908+
orientationSensor = orientationSensor ?: OrientationSensor(requireContext(), mMapView)
909+
}
903910
Toast.makeText(requireContext(), R.string.rotation_on, Toast.LENGTH_SHORT).show()
904911
} else {
905912
stopOrientationSensor()

0 commit comments

Comments
 (0)