Skip to content

Commit ab29d95

Browse files
authored
Merge pull request #3340 from Ghabry/android
Android: Reload native libraries on resume
2 parents e07493f + 3f1fae8 commit ab29d95

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
package org.easyrpg.player;
22

33
import android.os.Bundle;
4+
import android.util.Log;
5+
46
import androidx.appcompat.app.AppCompatActivity;
57
import org.easyrpg.player.settings.SettingsManager;
68

7-
public class BaseActivity extends AppCompatActivity {
9+
/**
10+
* This activity is used by the GameBrowser and the settings.
11+
*/
12+
public class BaseActivity extends AppCompatActivity {
13+
public static Boolean libraryLoaded = false;
14+
15+
private static void loadNativeLibraries() {
16+
if (!libraryLoaded) {
17+
try {
18+
System.loadLibrary("easyrpg_android");
19+
System.loadLibrary("gamebrowser");
20+
libraryLoaded = true;
21+
} catch (UnsatisfiedLinkError e) {
22+
Log.e("EasyRPG Player", "Couldn't load libgamebrowser: " + e.getMessage());
23+
throw e;
24+
}
25+
}
26+
}
27+
828
@Override
929
protected void onCreate(Bundle savedInstanceState) {
1030
super.onCreate(savedInstanceState);
1131

12-
// Retrieve User's preferences
13-
SettingsManager.init(getApplicationContext());
32+
init();
1433
}
1534

1635
@Override
1736
protected void onResume() {
1837
super.onResume();
1938

39+
init();
40+
}
41+
42+
protected void init() {
2043
// Retrieve User's preferences
2144
SettingsManager.init(getApplicationContext());
45+
46+
loadNativeLibraries();
2247
}
2348
}

builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java

-13
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444

4545
public class GameBrowserActivity extends BaseActivity
4646
implements NavigationView.OnNavigationItemSelectedListener {
47-
public static Boolean libraryLoaded = false;
48-
4947
private static final int THUMBNAIL_HORIZONTAL_SIZE_DPI = 290;
5048
private static Game selectedGame;
5149

@@ -58,17 +56,6 @@ public class GameBrowserActivity extends BaseActivity
5856
protected void onCreate(Bundle savedInstanceState) {
5957
super.onCreate(savedInstanceState);
6058

61-
if (!libraryLoaded) {
62-
try {
63-
System.loadLibrary("easyrpg_android");
64-
System.loadLibrary("gamebrowser");
65-
libraryLoaded = true;
66-
} catch (UnsatisfiedLinkError e) {
67-
Log.e("EasyRPG Player", "Couldn't load libgamebrowser: " + e.getMessage());
68-
throw e;
69-
}
70-
}
71-
7259
SDL.setContext(getApplicationContext());
7360

7461
setContentView(R.layout.activity_games_browser);

0 commit comments

Comments
 (0)