예제 #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();

  }
예제 #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;
    }
  }
예제 #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;
    }
  }
예제 #4
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View jobFragmentView = inflater.inflate(R.layout.fragment_job, container, false);

    tvJobTime = (MyFontTextView) jobFragmentView.findViewById(R.id.tvJobTime);
    tvJobDistance = (MyFontTextView) jobFragmentView.findViewById(R.id.tvJobDistance);
    tvJobStatus = (MyFontTextView) jobFragmentView.findViewById(R.id.tvJobStatus);
    tvClientName = (MyFontTextView) jobFragmentView.findViewById(R.id.tvClientName);
    tvClientAddress = (MyFontTextView) jobFragmentView.findViewById(R.id.tvMerchantAddress);
    // tvClientPhoneNumber = (MyFontTextView) jobFragmentView
    // .findViewById(R.id.tvClientNumber);

    // tvClientRating = (RatingBar) jobFragmentView
    //		.findViewById(R.id.tvClientRating);
    ivClientProfilePicture = (ImageView) jobFragmentView.findViewById(R.id.ivClientImage);

    tvJobStatus.setOnClickListener(this);
    jobFragmentView.findViewById(R.id.tvJobCallClient).setOnClickListener(this);
    return jobFragmentView;
  }
예제 #5
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();
      }
    }
  }