Fixed Java string comparison with ""
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 241e4b9..176f07a 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -542,41 +542,39 @@ public class SDLActivity extends Activity {
*/
public void setOrientationBis(int w, int h, boolean resizable, String hint)
{
- int orientation = -1;
+ int orientation = -1;
- if (hint != "") {
- if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
+ if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
- } else if (hint.contains("LandscapeRight")) {
+ } else if (hint.contains("LandscapeRight")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
- } else if (hint.contains("LandscapeLeft")) {
+ } else if (hint.contains("LandscapeLeft")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
- } else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
+ } else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
- } else if (hint.contains("Portrait")) {
+ } else if (hint.contains("Portrait")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
- } else if (hint.contains("PortraitUpsideDown")) {
+ } else if (hint.contains("PortraitUpsideDown")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
- }
- }
-
- /* no valid hint */
- if (orientation == -1) {
- if (resizable) {
- /* no fixed orientation */
- } else {
- if (w > h) {
- orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
+ }
+
+ /* no valid hint */
+ if (orientation == -1) {
+ if (resizable) {
+ /* no fixed orientation */
} else {
- orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
+ if (w > h) {
+ orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
+ } else {
+ orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
+ }
}
- }
- }
+ }
- Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
- if (orientation != -1) {
- mSingleton.setRequestedOrientation(orientation);
- }
+ Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
+ if (orientation != -1) {
+ mSingleton.setRequestedOrientation(orientation);
+ }
}
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
index 34729f6..4b1473f 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
@@ -265,7 +265,7 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler_API12 {
public String getJoystickDescriptor(InputDevice joystickDevice) {
String desc = joystickDevice.getDescriptor();
- if (desc != null && desc != "") {
+ if (desc != null && !desc.isEmpty()) {
return desc;
}