Example #1
0
  private String[] GetBusPosition(String Str) {
    String uploadWebsite = "http://" + controller.URL_BASE + "/php/busposition?q=";
    String[] ArrayOfData = null;
    StreamConnection c = null;
    InputStream s = null;
    StringBuffer b = new StringBuffer();

    String url = uploadWebsite + Str;
    System.out.print(url);
    try {
      /* c = (StreamConnection)Connector.open(url);
      s = c.openDataInputStream();
      int ch;
      int k =0;
      while((ch = s.read()) != -1) {
            System.out.print((char) ch);
          b.append((char) ch);   }
      */
      String result; // = b.toString();
      result = "365E~~RTONO~~09:30:23~~12.21212~~89.23324234";
      //   System.out.print("in thread---------");
      // System.out.print(result);
      if (!result.equals("")) {

        ArrayOfData = StringUtil.split(result.toString().trim(), "~~");
      }
    } catch (Exception e) {
      System.out.print(e);
      controller.ShowPointingCanvas();
      controller.showAlert("Network Error", 3, AlertType.ERROR);
    }

    return ArrayOfData;
  }
Example #2
0
  public void commandAction(Command command, Displayable displayable) {
    if (command == camList) {
      controller.setCurrentScreen(this);
      controller.setCurrentScreen(this);
    }
    if (command == refreshList) {
      controller.showProgressBar();
      refreshCamList();
    }
    if (command == cmBack) {
      controller.getDisp().setCurrent(LiveCameras);
    }
    if (command == RefreshImage) {
      refreshImage();
    }
    if (command == viewImage) {

      refreshImage();
    }
    if (command == TrafOption) {
      if (this.getString(this.getSelectedIndex()).equals("Cameras")) {
        LiveCameras();

      } else if (this.getString(this.getSelectedIndex()).equals("Traffic Fines")) {

        if (VehicleNoForm == null) {

          VehicleNoForm = new Form("Traffic Fines");
          vehNo = new TextField("Vehicle Number", "", 100, TextField.ANY);

          VehicleNoForm.append(vehNo);
          VehicleNoForm.addCommand(Vehicleback);
          VehicleNoForm.addCommand(VehicleOk);

          VehicleNoForm.setCommandListener(this);
        }

        controller.setCurrentScreen(VehicleNoForm);

      } else {
        new Thread() {
          public void run() {
            getTrafficSpots();
          }
        }.start();
      }
    }
    if (command == bckMenu) {
      controller.MainMenu();
    }

    if (command == Vehicleback) {
      controller.setCurrentScreen(this);
    }
    if (command == VehicleOk) {
      if (vehNo.getString().equals("")) {

        controller.showAlert("Enter the vehicle number", 0, AlertType.ERROR);
      } else {

        controller.showProgressBar();
        new Thread() {
          public void run() {

            Downloader dwn = new Downloader(controller);
            String message =
                dwn.requestForData(
                    "http://125.17.140.50/notices/vehiclefinedetails.aspx?veh_no="
                        + vehNo.getString());
            vehNo.setString("");
            controller.showAlert(message, 0, AlertType.INFO);
          }
        }.start();

        new Thread() {
          public void run() {

            controller.setCurrentScreen(VehicleNoForm);
          }
        }.start();
      }
    }
  }