コード例 #1
0
  /**
   * This is an overrided call of text change. This method gets called on every text change in the
   * search box.
   *
   * @param textArea
   * @param previousText
   * @param currentText
   */
  public void onTextChange(
      PatchedTextArea textArea, String previousText, final String currentText) {
    if (!(Display.getInstance().getCurrent() instanceof FormInvitation)) {
      return;
    }
    Log.v(TAG, " ************* testing PatchedTextArea " + currentText);
    Log.v(TAG, " ************* String Length  " + currentText.length());
    final int index = currentText.lastIndexOf(';');

    Log.v(TAG, " ************* Last Index " + index);
    if (index > 0) {
      UIHelper.runOnLwuitUiThread(
          new Runnable() {
            public void run() {
              searchContactlist(currentText.substring(index + 1));
            }
          });

      Log.v(TAG, " ************* Last Character " + currentText.substring(index));
    } else {
      UIHelper.runOnLwuitUiThread(
          new Runnable() {
            public void run() {
              searchContactlist(currentText);
            }
          });
    }

    if (!inviteVector.isEmpty()) {
      inviteList.setSelectedIndex(0);
      inviteList.repaint();
    }
  }
コード例 #2
0
  /**
   * This method opens native LCDUI dialog on the screen for confirmation, when user clicks on
   * delete or unlink account from the list.
   *
   * @param message
   * @param textPositive
   * @param textNegative
   */
  private void showDialog(final String message, String textPositive, String textNegative) {

    Alert alertDialog =
        UIHelper.getAlertDialog(
            LBL_CONFIRM, message, textPositive, textNegative, AlertType.CONFIRMATION);
    alertDialog.setCommandListener(
        new CommandListener() {
          public void commandAction(javax.microedition.lcdui.Command c, Displayable d) {
            if (c.getLabel().equals(LBL_UNLINK)) {
              BaseRetryable addressUpdateRetryable =
                  new BaseRetryable() {
                    public void retry() {
                      new Thread() {
                        public void run() {

                          Log.v(TAG, "retrying...");
                          DisplayStackManager.showProgressForm(true, MSG_UNLINK_PROGRESS);
                          try {
                            MqttConnectionHandler.getMqttConnectionHandler().close();
                            if (ClientConnectionHandler.UnlinkAccount()) {
                              ModelUtils.deleteUser(null);
                              DisplayStackManager.showForm(AppState.getForm());
                            } else {
                              DisplayStackManager.showForm(DisplayStackManager.FORM_ERROR);
                            }
                          } catch (Exception ex) {

                            Log.v(TAG, "exception in unlink account:" + ex.getClass().getName());
                            if (ex instanceof IOException
                                || ex instanceof ConnectionFailedException) {
                              errorForm.setErrorMessage(NO_NETWORK_TITLE);
                            }
                            errorForm.show();
                          }
                        }
                      }.start();
                    }
                  };
              addressUpdateRetryable.retry();
            } else if (c.getLabel().equals(LBL_DELETE)) {
              BaseRetryable addressUpdateRetryable =
                  new BaseRetryable() {
                    public void retry() {
                      new Thread() {
                        public void run() {

                          Log.v(TAG, "retrying...");
                          DisplayStackManager.showProgressForm(true, MSG_DELETE_PROGRESS);
                          try {
                            MqttConnectionHandler.getMqttConnectionHandler().close();
                            if (ClientConnectionHandler.DeleteAccount()) {
                              ModelUtils.deleteUser(null);
                              DisplayStackManager.showForm(AppState.getForm());
                            } else {
                              DisplayStackManager.showForm(DisplayStackManager.FORM_ERROR);
                            }
                          } catch (Exception ex) {

                            Log.v(TAG, "exception in delete account:" + ex.getClass().getName());
                            if (ex instanceof IOException
                                || ex instanceof ConnectionFailedException) {
                              errorForm.setErrorMessage(NO_NETWORK_TITLE);
                            }
                            errorForm.show();
                          }
                        }
                      }.start();
                    }
                  };
              addressUpdateRetryable.retry();
            }
            if (c.getLabel().equals(LBL_CANCEL)) {

              DisplayStackManager.showForm(AppState.getForm());
            }
          }
        });

    javax.microedition.lcdui.Display.getDisplay(Hike.sMidlet)
        .setCurrent(
            alertDialog, javax.microedition.lcdui.Display.getDisplay(Hike.sMidlet).getCurrent());
  }