Update OrientationHelper.java

pull/928/head
Mattia Iavarone 5 years ago committed by GitHub
parent 3ba3d21971
commit 980783e269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      cameraview/src/main/java/com/otaliastudios/cameraview/internal/OrientationHelper.java

@ -38,7 +38,7 @@ public class OrientationHelper {
final DisplayManager.DisplayListener mDisplayOffsetListener; final DisplayManager.DisplayListener mDisplayOffsetListener;
private int mDisplayOffset = -1; private int mDisplayOffset = -1;
private boolean listenerEnabled; private boolean mEnabled;
/** /**
* Creates a new orientation helper. * Creates a new orientation helper.
@ -99,11 +99,11 @@ public class OrientationHelper {
* Enables this listener. * Enables this listener.
*/ */
public void enable() { public void enable() {
if(listenerEnabled) { if (mEnabled) {
//already enabled, will ignore call //already enabled, will ignore call
return; return;
} }
listenerEnabled = true; mEnabled = true;
mDisplayOffset = findDisplayOffset(); mDisplayOffset = findDisplayOffset();
if (Build.VERSION.SDK_INT >= 17) { if (Build.VERSION.SDK_INT >= 17) {
DisplayManager manager = (DisplayManager) DisplayManager manager = (DisplayManager)
@ -117,7 +117,8 @@ public class OrientationHelper {
* Disables this listener. * Disables this listener.
*/ */
public void disable() { public void disable() {
listenerEnabled = false; if (!mEnabled) return;
mEnabled = false;
mDeviceOrientationListener.disable(); mDeviceOrientationListener.disable();
if (Build.VERSION.SDK_INT >= 17) { if (Build.VERSION.SDK_INT >= 17) {
DisplayManager manager = (DisplayManager) DisplayManager manager = (DisplayManager)

Loading…
Cancel
Save