Remove unreachable code

Since the compile sdk is 19, the if check is always true since it's checking 19 >= 17. This also removes the need for the success boolean which would always be true.
This commit is contained in:
FlukiestEmperor 2020-04-23 22:21:28 -05:00
parent 44f62a97c2
commit 512d77e011
1 changed files with 2 additions and 30 deletions

View File

@ -28,8 +28,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class MainActivity extends AppCompatActivity {
@ -65,34 +63,8 @@ public class MainActivity extends AppCompatActivity {
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
boolean success = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(pixelSize);
display.getRealMetrics(metrics);
success = true;
} else {
try {
Method getRawHeight = Display.class.getMethod("getRawHeight");
Method getRawWidth = Display.class.getMethod("getRawWidth");
pixelSize.x = (Integer) getRawWidth.invoke(display);
pixelSize.y = (Integer) getRawHeight.invoke(display);
success = true;
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
if (!success) {
// Fall back to viewport size
display.getSize(pixelSize);
}
display.getRealSize(pixelSize);
display.getRealMetrics(metrics);
int rotation = display.getRotation();
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {