v0.8.2a: removed some redundant work in onCreate

This commit is contained in:
Evan Debenham 2020-08-13 17:09:13 -04:00
parent cf22867666
commit 380faca85d
2 changed files with 38 additions and 27 deletions

View File

@ -50,27 +50,30 @@ public class AndroidGame extends AndroidApplication {
protected void onCreate (Bundle savedInstanceState) { protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
//there are some things we only need to set up on first launch
if (instance == null) {
instance = this; instance = this;
try { try {
Game.version = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionName; Game.version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Game.version = "???"; Game.version = "???";
} }
try { try {
Game.versionCode = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionCode; Game.versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Game.versionCode = 0; Game.versionCode = 0;
} }
if (UpdateImpl.supportsUpdates()){ if (UpdateImpl.supportsUpdates()) {
Updates.service = UpdateImpl.getUpdateService(); Updates.service = UpdateImpl.getUpdateService();
} }
if (NewsImpl.supportsNews()){ if (NewsImpl.supportsNews()) {
News.service = NewsImpl.getNewsService(); News.service = NewsImpl.getNewsService();
} }
FileUtils.setDefaultFileProperties( Files.FileType.Local, "" ); FileUtils.setDefaultFileProperties(Files.FileType.Local, "");
// grab preferences directly using our instance first // grab preferences directly using our instance first
// so that we don't need to rely on Gdx.app, which isn't initialized yet. // so that we don't need to rely on Gdx.app, which isn't initialized yet.
@ -78,9 +81,13 @@ public class AndroidGame extends AndroidApplication {
// this is the default prefs filename given to an android app (.xml is automatically added to it) // this is the default prefs filename given to an android app (.xml is automatically added to it)
SPDSettings.set(instance.getPreferences("ShatteredPixelDungeon")); SPDSettings.set(instance.getPreferences("ShatteredPixelDungeon"));
} else {
instance = this;
}
//set desired orientation (if it exists) before initializing the app. //set desired orientation (if it exists) before initializing the app.
if (SPDSettings.landscape() != null) { if (SPDSettings.landscape() != null) {
AndroidGame.instance.setRequestedOrientation( SPDSettings.landscape() ? instance.setRequestedOrientation( SPDSettings.landscape() ?
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT ); ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
} }

View File

@ -131,6 +131,10 @@ public class SPDAction extends GameAction {
public static void loadBindings(){ public static void loadBindings(){
if (!KeyBindings.getAllBindings().isEmpty()){
return;
}
try { try {
Bundle b = FileUtils.bundleFromFile(BINDINGS_FILE); Bundle b = FileUtils.bundleFromFile(BINDINGS_FILE);