/**
  * Invokes onTimeout() method for ResponseCallback object on application thread For example,
  * displays a pop-up dialog to the user with a given message
  *
  * @param timeout Timeout, in seconds
  */
 public void timeoutDialog(final int timeout) {
   _app.invokeLater(
       new Runnable() {
         public void run() {
           onTimeout(timeout);
         }
       });
 }
 /**
  * Invokes onResponse() method for ResponseCallback object on application thread to update UI
  * component depending on results of response message
  *
  * @param message The text to display
  */
 public void updateUI(final Message message) {
   _app.invokeLater(
       new Runnable() {
         public void run() {
           onResponse(message);
         }
       });
 }
 /**
  * Displays a pop-up dialog to the user with a given message
  *
  * @param message The text to display
  */
 public static void alertDialog(final String message) {
   _app.invokeLater(
       new Runnable() {
         public void run() {
           Dialog.alert(message);
         }
       });
 }
Beispiel #4
0
 // BluetoothScreenCallback
 public void onBluetoothScreenSelect(int index) {
   rhoLogInfo("onBluetoothScreenSelect(" + String.valueOf(index) + ")");
   UiApplication app = UiApplication.getUiApplication();
   final int i = index;
   app.invokeLater(
       new Runnable() {
         public void run() {
           getInstance().mPort = new BluetoothPort(mDevices[i], getInstance());
         }
       });
   mScreen = null;
 }
  /**
   * Display the specified URL in a custom browser screen.
   *
   * @param args JSONArry of arguments for the action.
   * @return a PluginResult
   */
  private synchronized PluginResult showWebPage(JSONArray args) {
    PluginResult result;

    if (browser == null) {
      try {
        boolean showLocationBar = true;
        String url = args.getString(0);
        JSONObject options = args.getJSONObject(1);

        // Determine whether to show or hide navigation bar.
        if (options != null) {
          showLocationBar = options.optBoolean("showLocationBar", true);
        }

        browser = new CustomBrowser(callbackId);
        if (browser.init(showLocationBar)) {
          uiApp.invokeLater(
              new Runnable() {
                public void run() {
                  uiApp.pushScreen(browser);
                }
              });

          browser.loadURL(url);

          // Must keep the callback for browser URL load and close
          // events.
          result = new PluginResult(PluginResult.Status.OK, "");
          result.setKeepCallback(true);
        } else {
          result =
              new PluginResult(
                  PluginResult.Status.ERROR, TAG + "Failed to initialize CustomBrowser.");
        }
      } catch (JSONException e) {
        return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
      }
    } else {
      result = new PluginResult(PluginResult.Status.ERROR, "ChildBrowser is already open.");
    }

    return result;
  }