summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>2013-05-05 15:54:56 +0200
committerPhilipp Wiesemann <philipp.wiesemann@arcor.de>2013-05-05 15:54:56 +0200
commitb6c14af95e19635d841fba207934253553f39863 (patch)
tree914b25b81209468e09bbcb0c8f8b24ae2b5f0557
parent1773e82524882b7b2207fc08baed1d2d4255d294 (diff)
Changed signatures of methods in Java file to return boolean, adapted C++ file.
This way more checking for errors is possible which is currently not done here.
-rw-r--r--android-project/src/org/libsdl/app/SDLActivity.java16
-rw-r--r--src/core/android/SDL_android.cpp14
2 files changed, 15 insertions, 15 deletions
diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java
index 9bdf1e7188..8b1495382c 100644
--- a/android-project/src/org/libsdl/app/SDLActivity.java
+++ b/android-project/src/org/libsdl/app/SDLActivity.java
@@ -170,11 +170,11 @@ public class SDLActivity extends Activity {
Handler commandHandler = new SDLCommandHandler();
// Send a message from the SDLMain thread
- void sendCommand(int command, Object data) {
+ boolean sendCommand(int command, Object data) {
Message msg = commandHandler.obtainMessage();
msg.arg1 = command;
msg.obj = data;
- commandHandler.sendMessage(msg);
+ return commandHandler.sendMessage(msg);
}
// C functions we call
@@ -202,13 +202,13 @@ public class SDLActivity extends Activity {
flipEGL();
}
- public static void setActivityTitle(String title) {
+ public static boolean setActivityTitle(String title) {
// Called from SDLMain() thread and can't directly affect the view
- mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
+ return mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
}
- public static void sendMessage(int command, int param) {
- mSingleton.sendCommand(command, Integer.valueOf(param));
+ public static boolean sendMessage(int command, int param) {
+ return mSingleton.sendCommand(command, Integer.valueOf(param));
}
public static Context getContext() {
@@ -271,9 +271,9 @@ public class SDLActivity extends Activity {
}
}
- public static void showTextInput(int x, int y, int w, int h) {
+ public static boolean showTextInput(int x, int y, int w, int h) {
// Transfer the task to the main thread as a Runnable
- mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h));
+ return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h));
}
diff --git a/src/core/android/SDL_android.cpp b/src/core/android/SDL_android.cpp
index e6a365dce2..ceb3555b0d 100644
--- a/src/core/android/SDL_android.cpp
+++ b/src/core/android/SDL_android.cpp
@@ -339,10 +339,10 @@ extern "C" void Android_JNI_SetActivityTitle(const char *title)
{
jmethodID mid;
JNIEnv *mEnv = Android_JNI_GetEnv();
- mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
+ mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)Z");
if (mid) {
jstring jtitle = reinterpret_cast<jstring>(mEnv->NewStringUTF(title));
- mEnv->CallStaticVoidMethod(mActivityClass, mid, jtitle);
+ mEnv->CallStaticBooleanMethod(mActivityClass, mid, jtitle);
mEnv->DeleteLocalRef(jtitle);
}
}
@@ -1085,12 +1085,12 @@ extern "C" int Android_JNI_SendMessage(int command, int param)
if (!env) {
return -1;
}
- jmethodID mid = env->GetStaticMethodID(mActivityClass, "sendMessage", "(II)V");
+ jmethodID mid = env->GetStaticMethodID(mActivityClass, "sendMessage", "(II)Z");
if (!mid) {
return -1;
}
- env->CallStaticVoidMethod(mActivityClass, mid, command, param);
- return 0;
+ jboolean success = env->CallStaticBooleanMethod(mActivityClass, mid, command, param);
+ return success ? 0 : -1;
}
extern "C" void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
@@ -1100,11 +1100,11 @@ extern "C" void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
return;
}
- jmethodID mid = env->GetStaticMethodID(mActivityClass, "showTextInput", "(IIII)V");
+ jmethodID mid = env->GetStaticMethodID(mActivityClass, "showTextInput", "(IIII)Z");
if (!mid) {
return;
}
- env->CallStaticVoidMethod( mActivityClass, mid,
+ env->CallStaticBooleanMethod( mActivityClass, mid,
inputRect->x,
inputRect->y,
inputRect->w,