Exemplo n.º 1
0
 public static void runOnEventThread(Runnable r) {
   if (Application.isEventDispatchThread()) {
     r.run();
   } else {
     Application.getApplication().invokeLater(r);
   }
 }
Exemplo n.º 2
0
  private void processPushMessage(final byte[] data) {
    Application.getApplication()
        .invokeLater(
            new Runnable() {
              public void run() {
                String msg = new String(data);
                LOG.TRACE("Triger sync on PUSH message [" + msg + " ]\n");

                String[] op;
                String[] ops = split(msg, "\n");
                for (int loop = 0; loop < ops.length; loop++) {
                  if (ops[loop].startsWith("do_sync")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length <= 1 || "all".equalsIgnoreCase(op[1])) {
                      SyncThread.doSyncAllSources();
                    } else if ((op[1] != null) && (op[1].length() > 0)) {
                      SyncThread.doSyncSource(op[1].trim());
                    }
                  } else if (ops[loop].startsWith("show_popup")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length > 1) {
                      showPopup(op[1]);
                    }
                  } else if (ops[loop].startsWith("vibrate")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length > 1) {
                      vibrate(op[1]);
                    } else {
                      vibrate("2500");
                    }
                  } else if (ops[loop].startsWith("play_file")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length > 1) {
                      op = splitOnce(op[1], ",");
                      if (op.length > 1) {
                        play_file(op[0], op[1]);
                      } else {
                        play_file(op[0], null);
                      }
                    }
                  }
                }
              }
            });
  }