diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/OrientationHelperTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/OrientationHelperTest.java index d2e0cea4..f4d66425 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/OrientationHelperTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/OrientationHelperTest.java @@ -90,5 +90,10 @@ public class OrientationHelperTest extends BaseTest { helper.mListener.onOrientationChanged(270); assertEquals(helper.getDeviceOrientation(), 270); verify(callback, times(1)).onDeviceOrientationChanged(270); + + // It is still 270 after ORIENTATION_UNKNOWN + helper.mListener.onOrientationChanged(OrientationEventListener.ORIENTATION_UNKNOWN); + assertEquals(helper.getDeviceOrientation(), 270); + verify(callback, times(1)).onDeviceOrientationChanged(270); } } diff --git a/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java b/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java index 8006d095..e104590c 100644 --- a/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java +++ b/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java @@ -28,7 +28,7 @@ class OrientationHelper { public void onOrientationChanged(int orientation) { int or = 0; if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) { - or = 0; + or = mDeviceOrientation != -1 ? mDeviceOrientation : 0; } else if (orientation >= 315 || orientation < 45) { or = 0; } else if (orientation >= 45 && orientation < 135) {