Ejemplo n.º 1
0
  private void getAddressFromLocation(final LatLng latlng, final MyFontTextView et) {

    /*
     * et.setText("Waiting for Address"); et.setTextColor(Color.GRAY);
     */
    /*
     * new Thread(new Runnable() {
     *
     * @Override public void run() { // TODO Auto-generated method stub
     */

    Geocoder gCoder = new Geocoder(getActivity());
    try {
      final List<Address> list = gCoder.getFromLocation(latlng.latitude, latlng.longitude, 1);
      if (list != null && list.size() > 0) {
        Address address = list.get(0);
        StringBuilder sb = new StringBuilder();
        if (address.getAddressLine(0) != null) {

          sb.append(address.getAddressLine(0)).append(", ");
        }
        sb.append(address.getLocality()).append(", ");
        // sb.append(address.getPostalCode()).append(",");
        sb.append(address.getCountryName());
        strAddress = sb.toString();

        strAddress = strAddress.replace(",null", "");
        strAddress = strAddress.replace("null", "");
        strAddress = strAddress.replace("Unnamed", "");
        if (!TextUtils.isEmpty(strAddress)) {

          et.setText(strAddress);
        }
      }
      /*
       * getActivity().runOnUiThread(new Runnable() {
       *
       * @Override public void run() { // TODO Auto-generated method stub
       * if (!TextUtils.isEmpty(strAddress)) {
       *
       * et.setText(strAddress);
       *
       *
       * } else { et.setText("");
       *
       * }
       *
       * } });
       */

    } catch (IOException exc) {
      exc.printStackTrace();
    }
    // }
    // }).start();

  }
Ejemplo n.º 2
0
  /** it is used for seeting text for jobstatus on textview */
  private void setjobStatus(int jobStatus) {

    switch (jobStatus) {
      case AndyConstants.IS_WALKER_STARTED:
        tvJobStatus.setText(mapActivity.getResources().getString(R.string.text_walker_started));
        break;
      case AndyConstants.IS_WALKER_ARRIVED:
        tvJobStatus.setText(mapActivity.getResources().getString(R.string.text_walker_arrived));
        break;
      case AndyConstants.IS_WALK_STARTED:
        tvJobStatus.setText(mapActivity.getResources().getString(R.string.text_walk_started));
        break;
      case AndyConstants.IS_WALK_COMPLETED:
        tvJobStatus.setText(mapActivity.getResources().getString(R.string.text_walk_completed));
        break;
      default:
        break;
    }
  }
Ejemplo n.º 3
0
  private void setClientDetails(RequestDetail requestDetail) {
    // Removed -- As part of "Removed - polling throughstartCheckingUpcomingRequests"
    tvClientName.setText(requestDetail.getClientName());
    tvClientAddress.setText(requestDetail.getClientAddress());

    // removed
    // if (requestDetail.getClientRating() != 0) {
    //	tvClientRating.setRating(requestDetail.getClientRating());
    // }
    if (requestDetail.getClientProfile() != null)
      if (!requestDetail.getClientProfile().equals(""))
        aQuery
            .id(ivClientProfilePicture)
            .progress(R.id.pBar)
            .image(requestDetail.getClientProfile());

    if (googleMap == null) {
      return;
    }
  }
Ejemplo n.º 4
0
  @Override
  public void onLocationReceived(LatLng latlong) {
    if (googleMap == null) {
      return;
    }

    if (markerClient_d_location == null) {
      if (requestDetail.getClient_d_latitude() != null
          && requestDetail.getClient_d_longitude() != null) {
        markerClient_d_location =
            googleMap.addMarker(
                new MarkerOptions()
                    .position(
                        new LatLng(
                            Double.parseDouble(requestDetail.getClient_d_latitude()),
                            Double.parseDouble(requestDetail.getClient_d_longitude())))
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_client))
                    .title("Destination"));
      }
    }

    if (markerClientLocation == null) {
      markerClientLocation =
          googleMap.addMarker(
              new MarkerOptions()
                  .position(
                      new LatLng(
                          Double.parseDouble(requestDetail.getClientLatitude()),
                          Double.parseDouble(requestDetail.getClientLongitude())))
                  .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_client)));

      if (jobStatus == AndyConstants.IS_WALK_COMPLETED) {
        markerClientLocation.setTitle(
            mapActivity.getResources().getString(R.string.job_start_location));
      } else {
        markerClientLocation.setTitle(
            mapActivity.getResources().getString(R.string.client_location));
      }
    }

    if (latlong != null) {
      if (googleMap != null) {
        if (markerDriverLocation == null) {
          markerDriverLocation =
              googleMap.addMarker(
                  new MarkerOptions()
                      .position(new LatLng(latlong.latitude, latlong.longitude))
                      .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_driver))
                      .title(getResources().getString(R.string.my_location)));
          googleMap.animateCamera(
              CameraUpdateFactory.newLatLngZoom(
                  new LatLng(latlong.latitude, latlong.longitude), 16));
        } else {
          markerDriverLocation.setPosition(new LatLng(latlong.latitude, latlong.longitude));
          if (jobStatus == AndyConstants.IS_WALK_COMPLETED) {
            drawTrip(new LatLng(latlong.latitude, latlong.longitude));

            // distance = decimalFormat.format(distanceMeter / (1000
            // * 1.62));

            // tvJobDistance.setText(decimalFormat
            // .format(preferenceHelper.getDistance()
            // / (1000 * 1.62))
            // + " "
            // + mapActivity.getResources().getString(
            // R.string.text_miles));

            tvJobDistance.setText(
                decimalFormat.format(
                        preferenceHelper.getDistance()
                        // / (1000 * 1.62))
                        )
                    + " "
                    + preferenceHelper.getUnit());
          }
        }
        // getDistance();
      }
    }
  }