Exemplo n.º 1
0
  @Override
  public boolean onMarkerClick(Marker marker) {

    Loadshopping driver = driverHashMap.get(marker);

    Intent intent = new Intent(mContext, OrderPickDriverActivity.class);

    intent.putExtra(Extras.DRIVER_ID, driver.getDriverId());

    intent.putExtra(Extras.DRIVER_NAME, Hex.decode(driver.getFullName()));

    Calendar birthCalendar =
        new DatetimeHelper().getCalendar(driver.getBirthDay(), DatetimeFormat.SERVER_DATE_FORMAT);
    int driverAge = Calendar.getInstance().get(Calendar.YEAR) - birthCalendar.get(Calendar.YEAR);
    intent.putExtra(Extras.DRIVER_AGE, driverAge);

    intent.putExtra(Extras.DRIVER_GENDER, driver.getGender());

    intent.putExtra(Extras.DRIVER_TOKEN, driver.getToken());

    intent.putExtra(Extras.DRIVER_LATLNG, marker.getPosition());

    startActivityForResult(intent, RequestCodes.PICK_DRIVER);

    return true;
  }
Exemplo n.º 2
0
  @Override
  public void onDriverReady(List<Loadshopping> drivers) {

    if (drivers.isEmpty()) {
      Snackbar.make(
              findViewById(R.id.tab_container),
              getString(R.string.snackbar_nodrivernearby),
              Snackbar.LENGTH_LONG)
          .show();
    } else {
      driverHashMap = new HashMap<>();
      for (Loadshopping driver : drivers) {

        String driverFullName = Hex.decode(driver.getFullName());
        LatLng driverLatLng =
            new LatLng(Double.valueOf(driver.getLatitude()), Double.valueOf(driver.getLongitude()));
        Marker marker =
            mMap.addMarker(
                new MarkerOptions()
                    .title(driverFullName)
                    .position(driverLatLng)
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_green_marker_filled)));

        driverHashMap.put(marker, driver);
      }
    }
  }