v0.9.1: more android lifecycle adjustments, fixes bugs and another leak?
This commit is contained in:
parent
e821eabaae
commit
8428d7cd89
|
@ -23,12 +23,10 @@ package com.shatteredpixel.shatteredpixeldungeon.android;
|
||||||
|
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.opengl.GLSurfaceView;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import com.badlogic.gdx.Files;
|
import com.badlogic.gdx.Files;
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||||
|
@ -43,7 +41,6 @@ import com.watabou.utils.FileUtils;
|
||||||
public class AndroidGame extends AndroidApplication {
|
public class AndroidGame extends AndroidApplication {
|
||||||
|
|
||||||
public static AndroidApplication instance;
|
public static AndroidApplication instance;
|
||||||
protected static GLSurfaceView view;
|
|
||||||
|
|
||||||
private static AndroidPlatformSupport support;
|
private static AndroidPlatformSupport support;
|
||||||
|
|
||||||
|
@ -112,8 +109,6 @@ public class AndroidGame extends AndroidApplication {
|
||||||
|
|
||||||
initialize(new ShatteredPixelDungeon(support), config);
|
initialize(new ShatteredPixelDungeon(support), config);
|
||||||
|
|
||||||
view = (GLSurfaceView)graphics.getView();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -134,16 +129,8 @@ public class AndroidGame extends AndroidApplication {
|
||||||
//LibGDX itself doesn't clear these in every case, so we do it ourselves to be sure
|
//LibGDX itself doesn't clear these in every case, so we do it ourselves to be sure
|
||||||
graphics.clearManagedCaches();
|
graphics.clearManagedCaches();
|
||||||
audio.dispose();
|
audio.dispose();
|
||||||
Gdx.app = null;
|
|
||||||
Gdx.input = null;
|
|
||||||
Gdx.audio = null;
|
|
||||||
Gdx.files = null;
|
|
||||||
Gdx.graphics = null;
|
|
||||||
Gdx.net = null;
|
|
||||||
|
|
||||||
if (instance == this) {
|
if (instance == this) {
|
||||||
instance = null;
|
instance = null;
|
||||||
view = null;
|
|
||||||
}
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,13 @@ import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
import android.opengl.GLSurfaceView;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.backends.android.AndroidGraphics;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
||||||
|
@ -53,12 +55,14 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
||||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
||||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLSurfaceView view = (GLSurfaceView) ((AndroidGraphics)Gdx.graphics).getView();
|
||||||
|
|
||||||
if (AndroidGame.view.getMeasuredWidth() == 0 || AndroidGame.view.getMeasuredHeight() == 0)
|
if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Game.dispWidth = AndroidGame.view.getMeasuredWidth();
|
Game.dispWidth = view.getMeasuredWidth();
|
||||||
Game.dispHeight = AndroidGame.view.getMeasuredHeight();
|
Game.dispHeight = view.getMeasuredHeight();
|
||||||
|
|
||||||
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
||||||
|| !AndroidGame.instance.isInMultiWindowMode();
|
|| !AndroidGame.instance.isInMultiWindowMode();
|
||||||
|
@ -99,7 +103,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
||||||
AndroidGame.instance.runOnUiThread(new Runnable() {
|
AndroidGame.instance.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AndroidGame.view.getHolder().setFixedSize(finalW, finalH);
|
view.getHolder().setFixedSize(finalW, finalH);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -108,7 +112,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
||||||
AndroidGame.instance.runOnUiThread(new Runnable() {
|
AndroidGame.instance.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AndroidGame.view.getHolder().setSizeFromLayout();
|
view.getHolder().setSizeFromLayout();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user