|
|
@ -38,6 +38,8 @@ public class OrientationHelper { |
|
|
|
final DisplayManager.DisplayListener mDisplayOffsetListener; |
|
|
|
final DisplayManager.DisplayListener mDisplayOffsetListener; |
|
|
|
private int mDisplayOffset = -1; |
|
|
|
private int mDisplayOffset = -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean mEnabled; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Creates a new orientation helper. |
|
|
|
* Creates a new orientation helper. |
|
|
|
* @param context a valid context |
|
|
|
* @param context a valid context |
|
|
@ -97,6 +99,11 @@ public class OrientationHelper { |
|
|
|
* Enables this listener. |
|
|
|
* Enables this listener. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void enable() { |
|
|
|
public void enable() { |
|
|
|
|
|
|
|
if (mEnabled) { |
|
|
|
|
|
|
|
//already enabled, will ignore call
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mEnabled = true; |
|
|
|
mDisplayOffset = findDisplayOffset(); |
|
|
|
mDisplayOffset = findDisplayOffset(); |
|
|
|
if (Build.VERSION.SDK_INT >= 17) { |
|
|
|
if (Build.VERSION.SDK_INT >= 17) { |
|
|
|
DisplayManager manager = (DisplayManager) |
|
|
|
DisplayManager manager = (DisplayManager) |
|
|
@ -110,6 +117,8 @@ public class OrientationHelper { |
|
|
|
* Disables this listener. |
|
|
|
* Disables this listener. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void disable() { |
|
|
|
public void disable() { |
|
|
|
|
|
|
|
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) |
|
|
|