Move the java code.

This commit is contained in:
Henrique Gemignani Passos Lima
2017-02-19 10:41:46 -03:00
parent d32e6ada77
commit ab888ac39f
5 changed files with 52 additions and 1794 deletions
@@ -123,10 +123,6 @@ public class SDLActivity extends Activity {
Log.v(TAG, "onCreate(): " + mSingleton); Log.v(TAG, "onCreate(): " + mSingleton);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
SDLActivity.initialize();
// So we can call stuff from static callbacks
mSingleton = this;
// Load shared libraries // Load shared libraries
String errorMsgBrokenLib = ""; String errorMsgBrokenLib = "";
try { try {
@@ -163,21 +159,8 @@ public class SDLActivity extends Activity {
return; return;
} }
// Set up the surface startNative();
mSurface = new SDLSurface(getApplication());
if(Build.VERSION.SDK_INT >= 12) {
mJoystickHandler = new SDLJoystickHandler_API12();
}
else {
mJoystickHandler = new SDLJoystickHandler();
}
mLayout = new RelativeLayout(this);
mLayout.addView(mSurface);
setContentView(mLayout);
// Get filename from "Open with" of another application // Get filename from "Open with" of another application
Intent intent = getIntent(); Intent intent = getIntent();
@@ -254,27 +237,63 @@ public class SDLActivity extends Activity {
return; return;
} }
// Send a quit message to the application // love2d-mod-start: end main thread when opening new .love file
SDLActivity.mExitCalledFromJava = true; resetNative();
SDLActivity.nativeQuit(); // love2d-mod-end
// Now wait for the SDL thread to quit
if (SDLActivity.mSDLThread != null) {
try {
SDLActivity.mSDLThread.join();
} catch(Exception e) {
Log.v(TAG, "Problem stopping thread: " + e);
}
SDLActivity.mSDLThread = null;
//Log.v(TAG, "Finished waiting for SDL thread");
}
super.onDestroy(); super.onDestroy();
// Reset everything in case the user re opens the app // Reset everything in case the user re opens the app
SDLActivity.initialize(); SDLActivity.initialize();
} }
// love2d-mod-start: end main thread when opening new .love file
/** Ends the native thread.
*/
public void resetNative() {
Log.v("SDL", "resetNative()");
// Send a quit message to the application
SDLActivity.mExitCalledFromJava = true;
SDLActivity.nativeQuit();
// Now wait for the SDL thread to quit
if (SDLActivity.mSDLThread != null) {
try {
SDLActivity.mSDLThread.join();
} catch(Exception e) {
Log.v("SDL", "Problem stopping thread: " + e);
}
SDLActivity.mSDLThread = null;
//Log.v("SDL", "Finished waiting for SDL thread");
}
SDLActivity.initialize();
}
public void startNative() {
Log.v("SDL", "startNative()");
SDLActivity.initialize();
// So we can call stuff from static callbacks
mSingleton = this;
// Set up the surface
mSurface = new SDLSurface(getApplication());
if(Build.VERSION.SDK_INT >= 12) {
mJoystickHandler = new SDLJoystickHandler_API12();
}
else {
mJoystickHandler = new SDLJoystickHandler();
}
mLayout = new RelativeLayout(this);
mLayout.addView(mSurface);
setContentView(mLayout);
}
// love2d-mod-end
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) { public boolean dispatchKeyEvent(KeyEvent event) {
File diff suppressed because it is too large Load Diff