詹子聪 5 лет назад
Родитель
Сommit
36ddbd4c74

+ 6 - 9
cameraview/src/main/java/com/otaliastudios/cameraview/internal/OrientationHelper.java

@@ -35,13 +35,13 @@ public class OrientationHelper {
 
     @VisibleForTesting
     final OrientationEventListener mDeviceOrientationListener;
-    private int mDeviceOrientation = -1;
+    private int mDeviceOrientation = 0;
 
     @VisibleForTesting
     final DisplayManager.DisplayListener mDisplayOffsetListener;
-    private int mDisplayOffset = -1;
-    
-    private boolean mEnabled;
+    private int mDisplayOffset = 0;
+
+    private boolean mEnabled = true;
 
     /**
      * Creates a new orientation helper.
@@ -70,12 +70,10 @@ public class OrientationHelper {
                     deviceOrientation = 270;
                 }
 
-                /*if (deviceOrientation != mDeviceOrientation) {
+                if (deviceOrientation != mDeviceOrientation) {
                     mDeviceOrientation = deviceOrientation;
                     mCallback.onDeviceOrientationChanged(mDeviceOrientation);
-                }*/
-                mDeviceOrientation = 0;
-                mCallback.onDeviceOrientationChanged(mDeviceOrientation);
+                }
             }
         };
         if (Build.VERSION.SDK_INT >= 17) {
@@ -114,7 +112,6 @@ public class OrientationHelper {
             manager.registerDisplayListener(mDisplayOffsetListener, mHandler);
         }
         mDeviceOrientationListener.enable();
-        //mCallback.onDeviceOrientationChanged(0);
     }
 
     /**