Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Reload native libraries on resume #3340

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
package org.easyrpg.player;

import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;
import org.easyrpg.player.settings.SettingsManager;

public class BaseActivity extends AppCompatActivity {
/**
* This activity is used by the GameBrowser and the settings.
*/
public class BaseActivity extends AppCompatActivity {
public static Boolean libraryLoaded = false;

private static void loadNativeLibraries() {
if (!libraryLoaded) {
try {
System.loadLibrary("easyrpg_android");
System.loadLibrary("gamebrowser");
libraryLoaded = true;
} catch (UnsatisfiedLinkError e) {
Log.e("EasyRPG Player", "Couldn't load libgamebrowser: " + e.getMessage());
throw e;
}
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Retrieve User's preferences
SettingsManager.init(getApplicationContext());
init();
}

@Override
protected void onResume() {
super.onResume();

init();
}

protected void init() {
// Retrieve User's preferences
SettingsManager.init(getApplicationContext());

loadNativeLibraries();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

public class GameBrowserActivity extends BaseActivity
implements NavigationView.OnNavigationItemSelectedListener {
public static Boolean libraryLoaded = false;

private static final int THUMBNAIL_HORIZONTAL_SIZE_DPI = 290;
private static Game selectedGame;

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

if (!libraryLoaded) {
try {
System.loadLibrary("easyrpg_android");
System.loadLibrary("gamebrowser");
libraryLoaded = true;
} catch (UnsatisfiedLinkError e) {
Log.e("EasyRPG Player", "Couldn't load libgamebrowser: " + e.getMessage());
throw e;
}
}

SDL.setContext(getApplicationContext());

setContentView(R.layout.activity_games_browser);
Expand Down
Loading