Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
fixed
  • Loading branch information
cping committed Jun 14, 2019
1 parent fd44e85 commit cf69763
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions Java/Loon-Neo-Android/src/loon/android/Loon.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import loon.event.SysInput;
import loon.geom.RectBox;
import loon.geom.RectI;
import loon.utils.MathUtils;
import loon.utils.StringUtils;
import android.app.Activity;
import android.app.AlertDialog;
Expand Down Expand Up @@ -413,7 +414,11 @@ private static void checkFile(File file) throws IOException {

protected DisplayMetrics getSysDisplayMetrices() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
try {
getWindowManager().getDefaultDisplay().getMetrics(dm);
} catch (Throwable cause) {
cause.printStackTrace();
}
return dm;
}

Expand Down Expand Up @@ -647,7 +652,15 @@ protected boolean useOrientation() {

protected int orientation() {
boolean use = useOrientation();
int orientation = getRequestedOrientation();
int orientation = -1;
if (android.os.Build.VERSION.SDK_INT < 23) {
orientation = this.getRequestedOrientation();
} else {
try {
orientation = this.getResources().getConfiguration().orientation;
} catch (Throwable cause) {
}
}
LSetting setting = game.setting;
if (use) {
if (setting instanceof AndroidSetting) {
Expand All @@ -656,7 +669,8 @@ protected int orientation() {
orientation = aset.orientation;
}
}
} else {
}
if (orientation <= 0 || !use) {
if (setting.landscape()) {
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
} else {
Expand All @@ -674,10 +688,6 @@ protected float scaleFactor() {
return getResources().getDisplayMetrics().density;
}

protected int maxSimultaneousSounds() {
return 8;
}

public AndroidGameViewGL gameView() {
return gameView;
}
Expand Down Expand Up @@ -798,8 +808,8 @@ protected void updateViewSize(final boolean landscape, int width, int height, LM

RectBox d = getScreenDimension();

this.maxWidth = (int) d.getWidth();
this.maxHeight = (int) d.getHeight();
this.maxWidth = MathUtils.max((int) d.getWidth(), 1);
this.maxHeight = MathUtils.max((int) d.getHeight(), 1);

if (landscape && (d.getWidth() > d.getHeight())) {
maxWidth = (int) d.getWidth();
Expand Down Expand Up @@ -890,7 +900,12 @@ protected void updateViewSize(final boolean landscape, int width, int height, LM
LSystem.setScaleHeight(1f);

}

if (zoomWidth <= 0) {
zoomWidth = maxWidth;
}
if (zoomHeight <= 0) {
zoomHeight = maxHeight;
}
LSystem.setScaleWidth(((float) maxWidth) / zoomWidth);
LSystem.setScaleHeight(((float) maxHeight) / zoomHeight);
LSystem.viewSize.setSize(zoomWidth, zoomHeight);
Expand Down Expand Up @@ -979,6 +994,7 @@ public void removeView(final View view) {
}
}

@Override
public void setImmersiveMode(boolean use) {
if (!use || AndroidGame.getSDKVersion() < 19) {
return;
Expand Down
Binary file modified Java/loon-android-0.5-source.jar
Binary file not shown.
Binary file modified Java/loon-android-0.5.jar
Binary file not shown.
Binary file modified androidstudio-template.7z
Binary file not shown.
Binary file modified loon-gradle-template.7z
Binary file not shown.

0 comments on commit cf69763

Please sign in to comment.