public void taskEdited(Task task) {
    task.updateEvent();
    com.zavitz.mytasks.functions.PersistentUtils.save();

    UiApplication.getUiApplication().popScreen(this);
    UiApplication.getUiApplication().pushScreen(new TaskScreen(task));
  }
  public void process(String val) {
    int fromIndex = -1;
    if ((fromIndex = val.indexOf(Const.xml_success)) != -1) {
      if (val.substring(
              fromIndex + Const.xml_success_length, val.indexOf(Const.xml_success_end, fromIndex))
          .equals("1")) {
        synchronized (UiApplication.getEventLock()) {
          try {
            lblBuyNowPrice.setText("");
            lblAuctionDuration.setText("");
            lblOpeningBid.setText("Auction successfully created!");
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      } else {
        synchronized (UiApplication.getEventLock()) {
          try {
            lblBuyNowPrice.setText("");
            lblAuctionDuration.setText("");
            lblOpeningBid.setText("Error creating auction.");
          } catch (Exception e) {

          }
        }
      }
    }
  }
  /** Unregisters file system listener and closes native voice notes recorder application. */
  protected void teardown() {
    // remove file system listener
    synchronized (UiApplication.getEventLock()) {
      UiApplication.getUiApplication().removeFileSystemJournalListener(listener);
    }

    // close the native voice notes recorder application
    AudioControl.closeAudioRecorder();
  }
  /** Registers file system listener and launches native voice notes recorder application. */
  protected void setup() {
    // register listener for files being written
    synchronized (UiApplication.getEventLock()) {
      UiApplication.getUiApplication().addFileSystemJournalListener(listener);
    }

    // launch the native voice notes recorder application
    AudioControl.launchAudioRecorder();
  }
Beispiel #5
0
  public void addToActive(TombolRoomField tf) {
    if (!DBStor.get_setting().isTest() && !DeviceInfo.isSimulator()) {
      Dialog.alert("Please try Test Push, until get Success notification.");
      return;
    }
    PushController.updateIndicator(false);
    if (Integer.parseInt(tf.getTotalperson()) > 49) {
      Dialog.alert("Room Full!");
    }
    int n = 0, a = 0;
    for (n = 0; n < chatss.length; n++) {
      ChatScreen css = chatss[n];
      if (css != null) {
        a++;
      }
    }
    if (a < 5) {
      ChatScreen cs;

      for (n = 0; n < chatss.length; n++) {
        cs = chatss[n];
        if (cs != null) {
          if (cs.getIdRoom().equals(tf.getRoom().getIdRoom())) {
            UiApplication.getUiApplication().pushScreen(cs);
            return;
          }
        }
      }
      TombolRoomField tfs = new TombolRoomField(tf.getRoom(), "0", USE_ALL_WIDTH);
      tfs.setChangeListener(this);
      tfs.setActive(true);
      AktifRoom.add(tfs);
      cs = new ChatScreen(tf.getRoom().getIdRoom(), tfs.getLabel(), this, tfs);
      for (n = 0; n < chatss.length; n++) {
        ChatScreen css = chatss[n];
        if (css == null) {
          this.chatss[n] = cs;
          break;
        }
      }
      UiApplication.getUiApplication().pushScreen(cs);
      cs = null;
    } else {
      ChatScreen cs;
      for (n = 0; n < chatss.length; n++) {
        cs = chatss[n];
        if (cs != null) {
          if (cs.getIdRoom().equals(tf.getRoom().getIdRoom())) {
            UiApplication.getUiApplication().pushScreen(cs);
            return;
          }
        }
      }
      Dialog.alert("Max 5 Active Room");
    }
  }
Beispiel #6
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;
 }
Beispiel #7
0
 public void fieldChanged(Field f, int i) {
   if (f == exit) {
     screen = null;
     UiApplication.getUiApplication().popScreen(this);
   } else if (f instanceof ListItemField) {
     int category = ((ListItemField) (f)).getId();
     if (category > -1) {
       screen = new GamePlayScreen(false, category, 1, false, -1, 0, -1);
       UiApplication.getUiApplication().pushScreen(screen);
     }
   }
 }
 public void fieldChanged(Field field, int context) {
   ButtonField btn4 = (ButtonField) field;
   if (btn4.getLabel().toString() == "Next") {
     cs6.storeUIFieldsToCitation();
     if (cs6.field_alcohol.getChecked() == true) {
       UiApplication.getUiApplication().pushScreen(new CitationScreen7(c));
     } else {
       UiApplication.getUiApplication().pushScreen(new CitationScreen8(c));
     }
   } else if (btn4.getLabel().toString() == "Prev") {
     cs6.storeUIFieldsToCitation();
     UiApplication.getUiApplication().popScreen(cs6);
   }
 }
 public boolean keyChar(char c, int status, int time) {
   handleSearchType();
   switch (c) {
     case Characters.ENTER:
       return true;
     case Characters.ESCAPE:
       UiApplication.getUiApplication()
           .popScreen(UiApplication.getUiApplication().getActiveScreen());
       return true;
     default:
       boolean retValue = super.keyChar(c, status, time);
       handleSearchType();
       return retValue;
   }
 }
 /**
  * Method for handling Field change events
  *
  * @param Field The field that changed
  * @param Information specifying the origin of the change
  */
 public void fieldChanged(Field field, int context) {
   if (field == goBack) {
     UiApplication.getUiApplication().pushScreen(new Game(currentUser));
   } else if (field == questionsList) {
     displayAnswer();
   }
 }
    public void run() {
      try {

        // serviceClient.setParameter("yozehariando");
        final TwitterApi[] twitterApis = serviceClient.getTwitterApi().getResult();

        UiApplication.getUiApplication()
            .invokeLater(
                new Runnable() {

                  public void run() {
                    while (twitterListField.getSize() > 0) {
                      twitterListField.delete(0);
                    }

                    if (twitterApis.length > 0) {
                      twitterListField.clear();

                      for (int i = 0; i < twitterApis.length; i++) {
                        log.debug("Screen : " + twitterApis[i].getText());
                        twitterListField.insert(twitterListField.getSize());
                        twitterListField.add(twitterApis[i]);
                      }
                      twitterListField.loadBitmap();
                    }
                  }
                });
      } catch (Exception e) {
        log.error(e.getMessage());
        fireaction(ERROR_ENTER, e.getMessage());
      }
    }
  private void convertHashTableToArray(Hashtable hashtable) {

    String icCodesString = (String) hashtable.get("stringval1");
    String productsString = (String) hashtable.get("stringval2");

    String[] icCodesArray = null;
    if (productsString != null) {

      if (icCodesString != null) {
        icCodesArray = StringSplitter.INSTANCE.split(icCodesString, "~");
      }

      String[] productsArray = StringSplitter.INSTANCE.split(productsString, "~");

      if (productsArray != null) {
        Constant.oldProductArray = productsArray;
      }
      if (icCodesArray != null) {
        Constant.oldICCodeArray = icCodesArray;
      }

    } else {
      UiApplication.getUiApplication()
          .invokeLater(
              new Runnable() {

                public void run() {
                  Dialog.alert(
                      "Failed to Refresh Product List for Visit info, Prerequisite configuration not available on server..");
                }
              });
    }
  }
  /**
   * Close a custom browser screen.
   *
   * @return a PluginResult
   */
  private synchronized PluginResult closeBrowser() {
    JSONObject obj = null;

    if (browser != null && browser.isDisplayed()) {
      uiApp.invokeAndWait(
          new Runnable() {
            public void run() {
              try {
                uiApp.popScreen(browser);
              } catch (IllegalArgumentException e) {
                Logger.log(
                    ChildBrowser.TAG + ": Caught illegal argument exception: " + e.getMessage());
              }
            }
          });
      browser = null;

      obj = new JSONObject();
      try {
        obj.put("type", CustomBrowser.CLOSE_EVENT);
      } catch (JSONException e) {
        return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
      }
    }

    return new PluginResult(PluginResult.Status.OK, obj);
  }
Beispiel #14
0
  public void AsyncDownloadImage(String url, final BitmapField fImg, final int resizew) {
    url += ";deviceside=true";
    final String furl = url;
    EncodedImage ei;

    UiApplication.getUiApplication()
        .invokeLater(
            new Runnable() {
              public void run() {
                InputStream inputStream = null;
                try {
                  ConnectionFactory cf = new ConnectionFactory();
                  cf.setConnectionTimeout(8333);
                  ConnectionDescriptor cd = cf.getConnection(furl);
                  HttpConnection httpConn;
                  httpConn = (HttpConnection) cd.getConnection();
                  inputStream = httpConn.openInputStream();
                  StringBuffer rawResponse = new StringBuffer();
                  byte[] responseData = new byte[10000];
                  int length = 0;
                  while (-1 != (length = inputStream.read(responseData))) {
                    rawResponse.append(new String(responseData, 0, length));
                  }
                  String result = rawResponse.toString();
                  byte[] dataArray = result.getBytes();
                  EncodedImage ei = EncodedImage.createEncodedImage(dataArray, 0, dataArray.length);
                  httpConn.close();
                  DownloadedImage(ei, fImg, resizew);
                } catch (Exception e1) {
                  ErrorImage(fImg, e1.toString());
                }
              }
            });
  }
  public void run() {
    try {
      player = Manager.createPlayer("capture://audio?encoding=audio/basic");
      player.realize();

      rCtl = (RecordControl) player.getControl("RecordControl");

      Control[] c = player.getControls();
      for (int i = c.length - 1; i >= 0; i--) {
        if (c[i] instanceof AudioPathControl) {
          apc = (AudioPathControl) c[i];

          oldPath = apc.getAudioPath();
          apc.setAudioPath(AudioPathControl.AUDIO_PATH_HANDSFREE);
          path = apc.getAudioPath();

          break;
        }
      }

      rCtl.setRecordStream(strm);
      rCtl.startRecord();

      player.start();
    } catch (Exception e) {
      final String msg = e.toString();
      UiApplication.getUiApplication()
          .invokeAndWait(
              new Runnable() {
                public void run() {
                  Dialog.inform(msg);
                }
              });
    }
  }
    public void run() {
      while (keepGoing) {
        UiApplication.getUiApplication()
            .invokeAndWait(
                new Runnable() {

                  public void run() {
                    theField.invalidate();
                  }
                });

        try {
          long l = image.getFrameDelay(currentFrame) * 10;
          sleep(l);
        } catch (InterruptedException iex) {
        }

        ++currentFrame;

        if (currentFrame == totalFrames) {
          currentFrame = 0;

          ++loopCount;

          if (loopCount == totalLoops) {
            keepGoing = false;
          }
        }
      }
    }
 public void clickButton() {
   try {
     UiApplication.getUiApplication()
         .pushScreen(new NewsDetailScreen((NewsScreen) this.getScreen(), newsItem, newsImage));
   } catch (Exception ex) {
   }
 }
  /** @see java.lang.Runnable#run() */
  public void run() {
    // Perform random actions to the message store every three seconds
    MessageListDemoStore messageStore = MessageListDemoStore.getInstance();
    while (_keepRunning) {
      try {
        synchronized (messageStore) {
          performAction(messageStore);
        }
      } catch (Exception e) {

      }
      try {
        synchronized (this) {
          wait(300000);
        }
      } catch (final InterruptedException e) {
        UiApplication.getUiApplication()
            .invokeLater(
                new Runnable() {
                  public void run() {
                    Dialog.alert("Thread#wait(long) threw " + e.toString());
                  }
                });

        return;
      }
    }
  }
    public void run() {
      while (_keepGoing) {
        // Invalidate the field so that it is redrawn.
        UiApplication.getUiApplication()
            .invokeAndWait(
                new Runnable() {
                  public void run() {
                    _theField.invalidate();
                  }
                });

        try {
          // Sleep for the current frame delay before the next frame is drawn.
          sleep(_image.getFrameDelay(_currentFrame) * 10);
        } catch (InterruptedException iex) {
        } // Couldn't sleep.

        // Increment the frame.
        ++_currentFrame;

        if (_currentFrame == _totalFrames) {
          // Reset back to frame 0 if we have reached the end.
          _currentFrame = 0;

          ++_loopCount;

          // Check if the animation should continue.
          if (_loopCount == _totalLoops) {
            _keepGoing = false;
          }
        }
      }
    }
Beispiel #20
0
 public Layout(CMainScreen c) {
   super(c);
   UiApplication ui = UiApplication.getUiApplication();
   theApp = (UiApplication) ui;
   strings = new Strings();
   setUpAssets();
 }
Beispiel #21
0
 public void fieldChanged(Field f, int i) {
   if (f == yes) {
     doConnect(Const.savecard + card.getId());
   } else if (f == no) {
     UiApplication.getUiApplication().popScreen(this);
   }
 }
 /**
  * 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);
         }
       });
 }
  /**
   * This method displays the correct answer field, either a short answer text box or multiple
   * answers, depending on the question type
   */
  private void displayAnswer() {

    int type = 0; // question type
    type_list = CreateQTypeList(); // retrieve types
    String question = (String) questionsList.getChoice(questionsList.getSelectedIndex());

    for (int i = 0; i < questions_list.length; i++) {
      if (questionsList.getSelectedIndex() == i) // questionList is the drop-down list
      type = type_list[i];
    }

    if (type == 0 && !(question.equals("None"))) // if  type is 0, display a panel with a text box
    {
      // displayAnswer constructor format: public DisplayAnswer(int type, String[] multAnswersArray,
      // String question,String currentUser, double QID, int week)
      UiApplication.getUiApplication()
          .pushScreen(
              new DisplayAnswer(
                  0,
                  null,
                  (String) questionsList.getChoice(questionsList.getSelectedIndex()),
                  currentUser,
                  question_object_array[questionsList.getSelectedIndex() - 1].getQID(),
                  week));

    } else if (type == 1
        && !(question.equals(
            "None"))) // if type is 1, display a panel with radio buttons for multiple answers
    {
      String multAnswers[] =
          question_object_array[questionsList.getSelectedIndex() - 1]
              .getMultAnswers(); // retrieve the multiple answers.
      // its length minus one because of the none string
      // displayAnswer constructor format: public DisplayAnswer(int type, String[] multAnswersArray,
      // String question,String currentUser, double QID, int week)
      UiApplication.getUiApplication()
          .pushScreen(
              new DisplayAnswer(
                  1,
                  multAnswers,
                  (String) questionsList.getChoice(questionsList.getSelectedIndex()),
                  currentUser,
                  question_object_array[questionsList.getSelectedIndex() - 1].getQID(),
                  week));
    }
  }
 /**
  * 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);
         }
       });
 }
 /*
  * Stop Scheduler Update when Escape this Screen
  */
 protected boolean keyChar(char c, int status, int time) {
   if (c == Characters.ESCAPE) {
     streamTimer.cancel();
     UiApplication.getUiApplication().popScreen(this);
     return true;
   }
   return false;
 }
Beispiel #27
0
 protected void onExposed() {
   SettingsBean _instance = SettingsBean.getSettings();
   synchronized (UiApplication.getEventLock()) {
     // notifications.setLabel((_instance.notifications?"*":"")+Const.notification);
   }
   if (_instance.notifications == false) {
     doConnect("notedate=1");
   }
 }
Beispiel #28
0
 public void hideWaitingScreen() {
   UiApplication.getUiApplication()
       .invokeLater(
           new Runnable() {
             public void run() {
               waiting_dialog.close();
             }
           });
 }
Beispiel #29
0
 protected void onExposed() {
   if (!isVisible()) {
     synchronized (UiApplication.getEventLock()) {
       bgManager.deleteAll();
       bgManager.add(header);
     }
     doConnect(Const.getusergames);
   }
 }
Beispiel #30
0
 public void showWaitingScreen() {
   UiApplication.getUiApplication()
       .invokeLater(
           new Runnable() {
             public void run() {
               waiting_dialog.doModal();
             }
           });
 }