Пример #1
0
  public static void updateUTF8Key(char c) {
    if (c_key_down_value_addr == 0) return;

    String s = String.valueOf(c);
    try {
      byte[] b = s.getBytes("UTF-8");
      CRunTime.memcpy(c_key_down_value_addr, b, 0, b.length);
      CRunTime.memoryWriteByte(c_key_down_value_addr + b.length, 0);
    } catch (Exception e) {
      CRunTime.memoryWriteByte(c_key_down_value_addr, 0);
      e.printStackTrace();
    }
  }
Пример #2
0
  public static void popUpYesNoDialog(
      final int textAddr,
      final String yesButtonStr,
      final String noButtonStr,
      final int yesCallback,
      final int noCallback,
      final int blocking) {
    final String sText = CRunTime.charPtrToString(textAddr, 8000);
    UiApplication.getUiApplication()
        .invokeAndWait(
            new Runnable() {
              public void run() {
                Dialog d =
                    new Dialog(
                        sText,
                        new String[] {noButtonStr, yesButtonStr},
                        new int[] {Dialog.NO, Dialog.YES},
                        Dialog.YES,
                        new Bitmap(0, 0));

                if (blocking == 0) {
                  // None blocking option
                  d.setDialogClosedListener(
                      new DialogClosedListener() {
                        public void dialogClosed(Dialog d, int dialogReturnValue) {
                          if (dialogReturnValue == Dialog.NO) {
                            try {
                              UIWorker.addUIEvent(noCallback, 0, 0, 0, 0, true);
                            } catch (Exception t) {
                              UIWorker.addUIEventLog(
                                  "Exception while calling noCallback in FreemapMainScreen.java -> popUpYesNoDialog"
                                      + t);
                            }
                          }

                          if (dialogReturnValue == Dialog.YES) {;
                            try {
                              UIWorker.addUIEvent(yesCallback, 0, 0, 0, 0, true);
                            } catch (Exception t) {
                              UIWorker.addUIEventLog(
                                  "Exception while calling yesCallback in FreemapMainScreen.java -> popUpYesNoDialog"
                                      + t);
                            }
                          }
                        }
                      });
                  d.show();

                } else if (blocking == 1) {
                  int index_chosen;
                  index_chosen = d.doModal();
                  if (index_chosen == Dialog.YES) {
                    try {
                      UIWorker.addUIEvent(yesCallback, 0, 0, 0, 0, true);
                    } catch (Exception t) {
                      UIWorker.addUIEventLog(
                          "Exception while calling yesCallback in FreemapMainScreen.java -> popUpYesNoDialog"
                              + t);
                    }
                  } else if (index_chosen == Dialog.NO) {
                    try {
                      UIWorker.addUIEvent(noCallback, 0, 0, 0, 0, true);
                    } catch (Exception t) {
                      UIWorker.addUIEventLog(
                          "Exception while calling noCallback in FreemapMainScreen.java -> popUpYesNoDialog"
                              + t);
                    }
                  }
                } else {
                  UIWorker.addUIEventLog(
                      "ERROR - input parameter blocking in popUpYesNoDialog is not valid.");
                }
              }
            });
  }