예제 #1
0
  /**
   * This method is called by SDL using JNI. Shows the messagebox from UI thread and block calling
   * thread. buttonFlags, buttonIds and buttonTexts must have same length.
   *
   * @param buttonFlags array containing flags for every button.
   * @param buttonIds array containing id for every button.
   * @param buttonTexts array containing text for every button.
   * @param colors null for default or array of length 5 containing colors.
   * @return button id or -1.
   */
  public int messageboxShowMessageBox(
      final int flags,
      final String title,
      final String message,
      final int[] buttonFlags,
      final int[] buttonIds,
      final String[] buttonTexts,
      final int[] colors) {

    messageboxSelection[0] = -1;

    // sanity checks

    if ((buttonFlags.length != buttonIds.length) && (buttonIds.length != buttonTexts.length)) {
      return -1; // implementation broken
    }

    // collect arguments for Dialog

    final Bundle args = new Bundle();
    args.putInt("flags", flags);
    args.putString("title", title);
    args.putString("message", message);
    args.putIntArray("buttonFlags", buttonFlags);
    args.putIntArray("buttonIds", buttonIds);
    args.putStringArray("buttonTexts", buttonTexts);
    args.putIntArray("colors", colors);

    // trigger Dialog creation on UI thread

    runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            showDialog(dialogs++, args);
          }
        });

    // block the calling thread

    synchronized (messageboxSelection) {
      try {
        messageboxSelection.wait();
      } catch (InterruptedException ex) {
        ex.printStackTrace();
        return -1;
      }
    }

    // return selected value

    return messageboxSelection[0];
  }
예제 #2
0
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putInt("x", x);
 }
예제 #3
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   outState.putInt("theme", mThemeId);
   super.onSaveInstanceState(outState);
 }
예제 #4
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   if (this.session != null) outState.putInt("sess_id", this.session.ID);
 }