Beispiel #1
1
  public void commandAction(Command command, Displayable displayable) {

    if (command == back) {
      controller.MainMenu();
    }
    if (command == viewStages) {
      busNos = busNo.getString().toUpperCase();
      fetchStagesData(busNos);
    }
    if (command == backToNo) {

      controller.getDisp().setCurrent(this);
    }
    if (command == MapStages) {
      controller.pointresultCanvas.busStagesPoints.removeAllElements();
      for (int mapStages = 0; mapStages < PostionAddress.length - 1; mapStages++) {
        String pos = PostionAddress[mapStages];
        String[] point = StringUtil.split(pos, "||");
        System.out.println(point[0] + "== " + point[1]);
        controller.pointBusStages(point[0], point[1]);
      }

      String pos = PostionAddress[Stages.getSelectedIndex()];
      String[] point = StringUtil.split(pos, "||");
      controller.gotoSpot(point[0], point[1]);
      controller.ShowPointingCanvas();
    }
    if (command == backToPlaces) {

      controller.getDisp().setCurrent(Stages);
    }
    if (command == showBuses) {
      controller.showProgressBar();
      fetchBusNoData();
    }
    if (command == showStages) {
      busNos = busesNearMe.getString(busesNearMe.getSelectedIndex()).toUpperCase();
      fetchStagesData(busNos);
    }
    if (command == viewBusPosition) {

      String[] data = GetBusPosition("Tt");
      String Message = "" + data[0] + "\n" + data[1] + "\n" + data[2];
      controller.showBusPosition(Message, data[3], data[4]);
    }
  }
Beispiel #2
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;
  }
Beispiel #3
0
  private String[] GetDataFromSite() {

    String uploadWebsite = "http://" + controller.selectedCity.URL + "/cameras/mobile_cam_list.php";
    String[] ArrayOfData = null;
    StreamConnection c = null;
    InputStream s = null;
    StringBuffer b = new StringBuffer();

    String url = uploadWebsite;
    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();
      if (!result.equals("")) {

        ArrayOfData = StringUtil.split(result.toString().trim(), "~~");
        if (ArrayOfData.length == 0) {
          controller.MainMenu();
          new Thread() {
            public void run() {
              controller.showAlert("Network Error", 0, AlertType.ERROR);
            }
          }.start();
        }
      }
    } catch (Exception e) {
      System.out.print(e);
      new Thread() {
        public void run() {
          controller.showProgressBar();
        }
      }.start();
      // controller.getDisp().setCurrent(this);

    }

    return ArrayOfData;
  }