Changed signatures of methods in Java file to return boolean, adapted C++ file.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 05 May 2013 15:54:56 +0200
changeset 7149534891ad4897
parent 7148 700a60e425cc
child 7150 151aa63ab281
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.
android-project/src/org/libsdl/app/SDLActivity.java
src/core/android/SDL_android.cpp
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun May 05 15:50:21 2013 +0200
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun May 05 15:54:56 2013 +0200
     1.3 @@ -170,11 +170,11 @@
     1.4      Handler commandHandler = new SDLCommandHandler();
     1.5  
     1.6      // Send a message from the SDLMain thread
     1.7 -    void sendCommand(int command, Object data) {
     1.8 +    boolean sendCommand(int command, Object data) {
     1.9          Message msg = commandHandler.obtainMessage();
    1.10          msg.arg1 = command;
    1.11          msg.obj = data;
    1.12 -        commandHandler.sendMessage(msg);
    1.13 +        return commandHandler.sendMessage(msg);
    1.14      }
    1.15  
    1.16      // C functions we call
    1.17 @@ -202,13 +202,13 @@
    1.18          flipEGL();
    1.19      }
    1.20  
    1.21 -    public static void setActivityTitle(String title) {
    1.22 +    public static boolean setActivityTitle(String title) {
    1.23          // Called from SDLMain() thread and can't directly affect the view
    1.24 -        mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
    1.25 +        return mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
    1.26      }
    1.27  
    1.28 -    public static void sendMessage(int command, int param) {
    1.29 -        mSingleton.sendCommand(command, Integer.valueOf(param));
    1.30 +    public static boolean sendMessage(int command, int param) {
    1.31 +        return mSingleton.sendCommand(command, Integer.valueOf(param));
    1.32      }
    1.33  
    1.34      public static Context getContext() {
    1.35 @@ -271,9 +271,9 @@
    1.36          }
    1.37      }
    1.38  
    1.39 -    public static void showTextInput(int x, int y, int w, int h) {
    1.40 +    public static boolean showTextInput(int x, int y, int w, int h) {
    1.41          // Transfer the task to the main thread as a Runnable
    1.42 -        mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h));
    1.43 +        return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h));
    1.44      }
    1.45  
    1.46  
     2.1 --- a/src/core/android/SDL_android.cpp	Sun May 05 15:50:21 2013 +0200
     2.2 +++ b/src/core/android/SDL_android.cpp	Sun May 05 15:54:56 2013 +0200
     2.3 @@ -339,10 +339,10 @@
     2.4  {
     2.5      jmethodID mid;
     2.6      JNIEnv *mEnv = Android_JNI_GetEnv();
     2.7 -    mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
     2.8 +    mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)Z");
     2.9      if (mid) {
    2.10          jstring jtitle = reinterpret_cast<jstring>(mEnv->NewStringUTF(title));
    2.11 -        mEnv->CallStaticVoidMethod(mActivityClass, mid, jtitle);
    2.12 +        mEnv->CallStaticBooleanMethod(mActivityClass, mid, jtitle);
    2.13          mEnv->DeleteLocalRef(jtitle);
    2.14      }
    2.15  }
    2.16 @@ -1085,12 +1085,12 @@
    2.17      if (!env) {
    2.18          return -1;
    2.19      }
    2.20 -    jmethodID mid = env->GetStaticMethodID(mActivityClass, "sendMessage", "(II)V");
    2.21 +    jmethodID mid = env->GetStaticMethodID(mActivityClass, "sendMessage", "(II)Z");
    2.22      if (!mid) {
    2.23          return -1;
    2.24      }
    2.25 -    env->CallStaticVoidMethod(mActivityClass, mid, command, param);
    2.26 -    return 0;
    2.27 +    jboolean success = env->CallStaticBooleanMethod(mActivityClass, mid, command, param);
    2.28 +    return success ? 0 : -1;
    2.29  }
    2.30  
    2.31  extern "C" void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
    2.32 @@ -1100,11 +1100,11 @@
    2.33          return;
    2.34      }
    2.35  
    2.36 -    jmethodID mid = env->GetStaticMethodID(mActivityClass, "showTextInput", "(IIII)V");
    2.37 +    jmethodID mid = env->GetStaticMethodID(mActivityClass, "showTextInput", "(IIII)Z");
    2.38      if (!mid) {
    2.39          return;
    2.40      }
    2.41 -    env->CallStaticVoidMethod( mActivityClass, mid,
    2.42 +    env->CallStaticBooleanMethod( mActivityClass, mid,
    2.43                                 inputRect->x,
    2.44                                 inputRect->y,
    2.45                                 inputRect->w,