コード例 #1
0
  public void onCheckIn(View view) {
    Logger.Debug("On check in click");
    if (this.currentPlace != null && this.currentPlace.getLocation() != null) {
      Intent intent = new Intent(this, FbPlacePicker.class);

      Location currentLocation = this.currentPlace.getLocation();
      intent.putExtra("latitude", currentLocation.getLatitude());
      intent.putExtra("longitude", currentLocation.getLongitude());
      intent.putExtra(PlacePickerFragment.RADIUS_IN_METERS_BUNDLE_KEY, 50);
      intent.putExtra(PlacePickerFragment.SHOW_SEARCH_BOX_BUNDLE_KEY, false);
      intent.putExtra(PlacePickerFragment.SEARCH_TEXT_BUNDLE_KEY, this.currentPlace.getName());

      android.location.Location location =
          new android.location.Location(LocationManager.GPS_PROVIDER);
      location.setLatitude(Double.valueOf(currentLocation.getLatitude()));
      location.setLongitude(Double.valueOf(currentLocation.getLongitude()));

      intent.putExtra(PlacePickerFragment.LOCATION_BUNDLE_KEY, location);

      this.startActivity(intent);
    }
  }
コード例 #2
0
  public void showPlace(Place place) {

    if (place != null) {
      this.currentPlace = place;
      // create place name.
      TextView name = (TextView) findViewById(R.id.place_name);
      if (name != null) {
        name.setText(place.getName());
      }

      // create PLACE description.
      TextView description = (TextView) findViewById(R.id.place_description);
      if (description != null) {
        String descStr = place.getDescription();

        if (descStr != null && !descStr.isEmpty() && !descStr.equals("null")) {
          description.setText(descStr);
        } else {
          description.setVisibility(View.GONE);
        }
      }

      if (place.getImage() != null && !place.getImage().isEmpty()) {
        // place image
        ImageView image = (ImageView) findViewById(R.id.place_image);
        if (image != null) {
          DataManager.getSingleton().downloadBitmap(place.getImage(), image);
        }
      }

      // place location
      Location location = place.getLocation();
      if (location != null) {
        TextView placeLocation = (TextView) findViewById(R.id.place_location);
        if (placeLocation != null) {
          placeLocation.setText(location.getAddress());
        }

        // place distance.
        TextView distance = (TextView) findViewById(R.id.place_distance);
        if (distance != null) {
          float[] distanceResults = new float[1];
          android.location.Location currentLocation = AppLocationManager.getCurrentLocation();
          DecimalFormat df = new DecimalFormat("#.#");

          if (currentLocation != null) {
            android.location.Location.distanceBetween(
                currentLocation.getLatitude(),
                currentLocation.getLongitude(),
                Double.valueOf(location.getLatitude()),
                Double.valueOf(location.getLongitude()),
                distanceResults);
            double miles = distanceResults[0] / 1609.34; // i mile =
            // 1.60934km
            distance.setText(df.format(miles) + "mi");
          } else {
            distance.setText("--");
          }
        }

        MapView map = (MapView) findViewById(R.id.mapview);
        if (map != null) {
          MapController mc = map.getController();
          if (mc != null) {

            List<Overlay> mapOverlaysList = map.getOverlays();
            Drawable drawable = this.getResources().getDrawable(R.drawable.red_pointer_icon);

            // creating an ItemizedOverlayActivity object so we can
            // have multiple overlays
            // added to a list to show them in a map
            ItemizedOverlayActivity itemizedoverlay = new ItemizedOverlayActivity(drawable, this);

            GeoPoint geoPoint =
                new GeoPoint(
                    (int) (Double.valueOf(location.getLatitude()) * 1E6),
                    (int) (Double.valueOf(location.getLongitude()) * 1E6));

            // Creates an overlay item with a geopoint to show in
            // the map
            OverlayItem overlayitem = new OverlayItem(geoPoint, "Place", place.getName());

            itemizedoverlay.addOverlay(overlayitem);
            mapOverlaysList.add(itemizedoverlay);

            mc.setCenter(geoPoint);
            mc.setZoom(17);
          }
        }

        showEventList(place.getEventsAtPlace());
      }
    }
  } // end showPlace