Exemplo n.º 1
0
        @Override
        public void run() {

          if (locationService != null) {

            current_location = locationService.getLatLngLocation();
            if (current_location != null) {

              //                        if (!httpRequested) {
              //                            googleMap.animateCamera(CameraUpdateFactory.newLatLng(
              // new LatLng(current_location.getLatitude(), current_location.getLongitude())));
              //                        }

              if (bDirUpdates) {
                Double asOften = (howOften <= 0.0 || howOften == null) ? 0.01 : howOften;
                if (LocationService.distanceTraveled(current_location, last_used_location)
                    >= asOften) {
                  if (dataConnected) {
                    drawDirections();
                  }
                }
              } else {

                drawCurrentLocation(current_location);
              }
            }
          }

          if (!paused) handler.postDelayed(this, (current_location == null) ? 1000 : 10000);
        }
Exemplo n.º 2
0
  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

    String[] colorArray = TrainColor.TRAIN_COLORS_ARRAY;
    if (position < 0 || position >= colorArray.length) {
      return;
    }

    if (!httpRequested || current_location == null) {
      return;
    }

    String trainColor = colorArray[position];
    color = (trainColor.equals("Any")) ? null : trainColor;
    firstTimeCameraMove = true;

    if (cachedJSONHash.size() != 0) {
      JSONObject closest_station = cachedJSONHash.get(trainColor);
      parseJSON(closest_station);
      if (dataConnected) {
        drawDirections();
      } else {
        noDataMessage();
      }
    }

    if (locationService.distanceTraveled(current_location, last_used_location) > 0.5) {
      httpRequested = false;
      if (dataConnected) {
        progressValue = 0;
        initializeProgressDialog();
        new HttpAsyncTask().execute();
      } else {
        noDataMessage();
      }
    }

    setColorTVText();
  }