Skip to content

Commit

Permalink
fix(android): device orientation will be converted to UNKNOWN during …
Browse files Browse the repository at this point in the history
…screen rotation
  • Loading branch information
Hiroenzo committed Jul 26, 2024
1 parent aa4ff82 commit 6c899ee
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.orientationdirector.implementation
import android.content.pm.ActivityInfo
import android.os.Handler
import android.os.Looper
import android.view.OrientationEventListener.ORIENTATION_UNKNOWN
import com.facebook.react.bridge.ReactApplicationContext

class OrientationDirectorImpl internal constructor(private val context: ReactApplicationContext) {
Expand Down Expand Up @@ -127,8 +128,15 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp

private fun onOrientationChanged(rawDeviceOrientation: Int) {
val deviceOrientation = mUtils.convertToDeviceOrientationFrom(rawDeviceOrientation)
mEventManager.sendDeviceOrientationDidChange(deviceOrientation.ordinal)
lastDeviceOrientation = deviceOrientation

if (rawDeviceOrientation != ORIENTATION_UNKNOWN && deviceOrientation == Orientation.UNKNOWN) {
return;
}

if (lastDeviceOrientation == deviceOrientation) {
return
}

adaptInterfaceTo(deviceOrientation)
}

Expand Down

0 comments on commit 6c899ee

Please sign in to comment.