Fixed Java string comparison with ""
authorSam Lantinga <slouken@libsdl.org>
Sun, 29 Oct 2017 21:09:09 -0700
changeset 116602119394cbc86
parent 11659 b2fd0f264cd3
child 11661 bd1495ebc979
Fixed Java string comparison with ""
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sat Oct 28 12:11:25 2017 -0700
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sun Oct 29 21:09:09 2017 -0700
     1.3 @@ -542,41 +542,39 @@
     1.4       */
     1.5      public void setOrientationBis(int w, int h, boolean resizable, String hint) 
     1.6      {
     1.7 -      int orientation = -1;
     1.8 +        int orientation = -1;
     1.9  
    1.10 -      if (hint != "") {
    1.11 -         if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
    1.12 +        if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
    1.13              orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
    1.14 -         } else if (hint.contains("LandscapeRight")) {
    1.15 +        } else if (hint.contains("LandscapeRight")) {
    1.16              orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    1.17 -         } else if (hint.contains("LandscapeLeft")) {
    1.18 +        } else if (hint.contains("LandscapeLeft")) {
    1.19              orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
    1.20 -         } else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
    1.21 +        } else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
    1.22              orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
    1.23 -         } else if (hint.contains("Portrait")) {
    1.24 +        } else if (hint.contains("Portrait")) {
    1.25              orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    1.26 -         } else if (hint.contains("PortraitUpsideDown")) {
    1.27 +        } else if (hint.contains("PortraitUpsideDown")) {
    1.28              orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
    1.29 -         }
    1.30 -      }
    1.31 +        }
    1.32  
    1.33 -      /* no valid hint */
    1.34 -      if (orientation == -1) {
    1.35 -         if (resizable) {
    1.36 -            /* no fixed orientation */
    1.37 -         } else {
    1.38 -            if (w > h) {
    1.39 -               orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
    1.40 +        /* no valid hint */
    1.41 +        if (orientation == -1) {
    1.42 +            if (resizable) {
    1.43 +                /* no fixed orientation */
    1.44              } else {
    1.45 -               orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
    1.46 +                if (w > h) {
    1.47 +                    orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
    1.48 +                } else {
    1.49 +                    orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
    1.50 +                }
    1.51              }
    1.52 -         }
    1.53 -      }
    1.54 +        }
    1.55  
    1.56 -      Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
    1.57 -      if (orientation != -1) {
    1.58 -         mSingleton.setRequestedOrientation(orientation);
    1.59 -      }
    1.60 +        Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
    1.61 +        if (orientation != -1) {
    1.62 +            mSingleton.setRequestedOrientation(orientation);
    1.63 +        }
    1.64      }
    1.65  
    1.66  
     2.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Sat Oct 28 12:11:25 2017 -0700
     2.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Sun Oct 29 21:09:09 2017 -0700
     2.3 @@ -265,7 +265,7 @@
     2.4      public String getJoystickDescriptor(InputDevice joystickDevice) {
     2.5          String desc = joystickDevice.getDescriptor();
     2.6  
     2.7 -        if (desc != null && desc != "") {
     2.8 +        if (desc != null && !desc.isEmpty()) {
     2.9              return desc;
    2.10          }
    2.11