mirror of
https://github.com/love2d/love-android.git
synced 2026-08-19 20:20:25 +02:00
Adjusted SDLActivity.java to allow restarting of the native thread
This commit is contained in:
+48
-29
@@ -187,30 +187,9 @@ public class SDLActivity extends Activity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up JNI
|
// love2d-mod-start: allow restarting of the native thread
|
||||||
SDL.setupJNI();
|
startNative();
|
||||||
|
// love2d-mod-end: allow restarting of the native thread
|
||||||
// Initialize state
|
|
||||||
SDL.initialize();
|
|
||||||
|
|
||||||
// So we can call stuff from static callbacks
|
|
||||||
mSingleton = this;
|
|
||||||
SDL.setContext(this);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
mClipboardHandler = new SDLClipboardHandler_API11();
|
|
||||||
} else {
|
|
||||||
/* Before API 11, no clipboard notification (eg no SDL_CLIPBOARDUPDATE) */
|
|
||||||
mClipboardHandler = new SDLClipboardHandler_Old();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up the surface
|
|
||||||
mSurface = new SDLSurface(getApplication());
|
|
||||||
|
|
||||||
mLayout = new RelativeLayout(this);
|
|
||||||
mLayout.addView(mSurface);
|
|
||||||
|
|
||||||
setContentView(mLayout);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Per SDL_androidwindow.c, Android will only ever have one window, and that window
|
* Per SDL_androidwindow.c, Android will only ever have one window, and that window
|
||||||
@@ -312,6 +291,17 @@ public class SDLActivity extends Activity {
|
|||||||
mNextNativeState = NativeState.PAUSED;
|
mNextNativeState = NativeState.PAUSED;
|
||||||
SDLActivity.handleNativeState();
|
SDLActivity.handleNativeState();
|
||||||
|
|
||||||
|
// love2d-mod-start: allow restarting of the native thread
|
||||||
|
resetNative();
|
||||||
|
// love2d-mod-end: allow restarting of the native thread
|
||||||
|
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// love2d-mod-start: allow restarting of the native thread
|
||||||
|
public void resetNative() {
|
||||||
|
Log.v("SDL", "resetNative()");
|
||||||
|
|
||||||
// Send a quit message to the application
|
// Send a quit message to the application
|
||||||
SDLActivity.mExitCalledFromJava = true;
|
SDLActivity.mExitCalledFromJava = true;
|
||||||
SDLActivity.nativeQuit();
|
SDLActivity.nativeQuit();
|
||||||
@@ -321,19 +311,48 @@ public class SDLActivity extends Activity {
|
|||||||
try {
|
try {
|
||||||
SDLActivity.mSDLThread.join();
|
SDLActivity.mSDLThread.join();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
Log.v(TAG, "Problem stopping thread: " + e);
|
Log.v("SDL", "Problem stopping thread: " + e);
|
||||||
}
|
}
|
||||||
SDLActivity.mSDLThread = null;
|
SDLActivity.mSDLThread = null;
|
||||||
|
|
||||||
//Log.v(TAG, "Finished waiting for SDL thread");
|
//Log.v("SDL", "Finished waiting for SDL thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
// Reset everything in case the user re opens the app
|
|
||||||
SDLActivity.initialize();
|
SDLActivity.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startNative() {
|
||||||
|
Log.v("SDL", "startNative()");
|
||||||
|
|
||||||
|
SDLActivity.initialize();
|
||||||
|
|
||||||
|
// Set up JNI
|
||||||
|
SDL.setupJNI();
|
||||||
|
|
||||||
|
// Initialize state
|
||||||
|
SDL.initialize();
|
||||||
|
|
||||||
|
// So we can call stuff from static callbacks
|
||||||
|
mSingleton = this;
|
||||||
|
SDL.setContext(this);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
|
mClipboardHandler = new SDLClipboardHandler_API11();
|
||||||
|
} else {
|
||||||
|
/* Before API 11, no clipboard notification (eg no SDL_CLIPBOARDUPDATE) */
|
||||||
|
mClipboardHandler = new SDLClipboardHandler_Old();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the surface
|
||||||
|
mSurface = new SDLSurface(getApplication());
|
||||||
|
|
||||||
|
mLayout = new RelativeLayout(this);
|
||||||
|
mLayout.addView(mSurface);
|
||||||
|
|
||||||
|
setContentView(mLayout);
|
||||||
|
}
|
||||||
|
// love2d-mod-end: allow restarting of the native thread
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user