Created
June 13, 2017 11:12
-
-
Save JakeSteam/b9503c46e65088e0e651dc75d9782979 to your computer and use it in GitHub Desktop.
"Auto-detecting Device Orientation Whilst Allowing User to Override" for GameDevAlgorithms.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onResume() { | |
super.onResume(); | |
//noinspection ResourceType | |
setRequestedOrientation(Setting.get(Enums.Setting.Orientation).getIntValue()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final static int ORIENTATION_AUTO = 4; | |
public final static int ORIENTATION_LANDSCAPE = 6; | |
public final static int ORIENTATION_PORTRAIT = 7; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int getOrientationValue(int position) { | |
switch (position) { | |
case 1: return Constants.ORIENTATION_LANDSCAPE; | |
case 2: return Constants.ORIENTATION_PORTRAIT; | |
default: return Constants.ORIENTATION_AUTO; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment