Skip to content

Commit

Permalink
fix: Don't send onOrientationChanged event if phone is flat on Andr…
Browse files Browse the repository at this point in the history
…oid (#3429)
  • Loading branch information
mrousavy authored Feb 20, 2025
1 parent 3a265c8 commit 7456c00
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class OrientationManager(private val context: Context, private val callback: Cal
private val orientationListener = object : OrientationEventListener(context) {
override fun onOrientationChanged(rotationDegrees: Int) {
// Phone rotated!
if (rotationDegrees == OrientationEventListener.ORIENTATION_UNKNOWN) {
// phone is laying flat - orientation is unknown! Avoid sending out event.
return
}
deviceRotation = degreesToSurfaceRotation(rotationDegrees)
maybeNotifyOrientationChanged()
}
Expand Down

0 comments on commit 7456c00

Please # to comment.