Package org.json.me

Examples of org.json.me.JSONObject


    if (command.getString("command").equals("stop")) {
      // stop DTs
      this.driveTrain.stop();
    }
    if (command.getString("command").equals("getstatus")) {
      JSONObject statusData = new JSONObject();
      // Put data into object..
      statusData.put("x", "" + driveTrain.getX());
      statusData.put("y", "" + driveTrain.getY());
      statusData.put("heading", "" + driveTrain.getHeading());
      statusData.put("arm", "" + arm.isExtended());
      statusData.put("firing", "" + cannon.isFiring());
      statusData.put("ready", "" + cannon.readyToFire());
     
      // Serialize it
      server.sendData(statusData.toString() + "\n");
    }
  }
View Full Code Here


        picker.setView(FilePicker.VIEW_PICTURES);
        String path = picker.show();

        if (path != null) {
          // Creating the data context as a JSONObject
          JSONObject context = new JSONObject();
          try {
            context.put(SendCommandContextKeys.PATH, path);
            /**
             * Since we are sharing a file path, you CANNOT add a
             * SUBJECT or TEXT type data. Only PATH seems to be
             * allowed.
             */
          } catch (JSONException e) {

          }

          /**
           * Getting the available SendCommand(s) for our SendCommand
           * type TYPE_TEXT by providing our data context. The 3rd
           * parameter is a boolean that indicates whether you want
           * all results or just the results that are possible based on the context.
           * Ideally this boolean param would be set to false,
           * but there seems to be a bug with BBM as it throws an
           * exception during the query. As a workaround, I am getting
           * all first and then filtering out the ones I dont need.
           */
          commandsAll = SendCommandRepository.getInstance().get(SendCommand.TYPE_PATH, context, true);
          commands = new SendCommand[2];
                   
          for (int i = 0; i < commandsAll.length; i++) {           
            if (commandsAll[i].getId().equals(TWITTER_PATH_ID)) {
              commands[0] = commandsAll[i];
            }
            if (commandsAll[i].getId().equals(FACEBOOK_PATH_ID)) {
              commands[1] = commandsAll[i];
            }
          }
          // Displays our SendCommands to the user.
          displayCommands();
        }

        return true;
      }

      public int getPreferredWidth() {
        return Display.getWidth()/2;
      }
    };

    add(filePickButton);

    add(new SeparatorField());
    add(new SeparatorField());
    add(new SeparatorField());

    // An EditField to let the user type in the text to share.
    textField = new EditField("", "Share this please.");
    textField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3)));
   
    // A button that initiates the Text Share
    shareTextButton = new ButtonField("Text Share", Field.FIELD_HCENTER) {
      protected boolean navigationClick(int arg0, int arg1) {
        // Creating the data context as a JSONObject
        JSONObject context = new JSONObject();
        try {
          context.put(SendCommandContextKeys.TEXT, textField.getText());
          /**
           * For text sharing, you can also add a subject as follows. This is useful for sharing via email.
           * context.put(SendCommandContextKeys.SUBJECT, "your subject");
           */
        } catch (JSONException e) {
View Full Code Here

     * @param text
     *            The textual context that will be used to query the
     *            SendCommandRepository for appropriate commands
     */
    private static void addSendMenuForText(final Menu menu, final String text) {
        final JSONObject context = new JSONObject();
        try {
            context.put(SendCommandContextKeys.TEXT, text);
            context.put(SendCommandContextKeys.SUBJECT, "Selected text");

        } catch (final JSONException e) {
            SendMenuDemo.errorDialog("JSONObject.put() threw " + e.toString());
        }

View Full Code Here

     * @param file
     *            The file context that will be used to query the
     *            SendCommandRepository for appropriate commands
     */
    private static void addSendMenuForFile(final Menu menu, final String file) {
        final JSONObject context = new JSONObject();
        try {
            context.put(SendCommandContextKeys.PATH, file);
        } catch (final JSONException e) {
            SendMenuDemo.errorDialog("JSONObject.put() threw " + e.toString());
        }

        // Query the SendCommandRepository for appropriate commands
View Full Code Here

TOP

Related Classes of org.json.me.JSONObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.