private boolean commonOnTap(GeoPoint tappedGeoPoint) {
    List<Uri> tappedUri = new Vector<Uri>();

    Point tappedPoint = new Point();
    mProjection.toPixels(tappedGeoPoint, tappedPoint);
    for (MediaVO media : mMediaPath) {
      if (media.x < tappedPoint.x
          && tappedPoint.x < media.x + media.w
          && media.y < tappedPoint.y
          && tappedPoint.y < media.y + media.h) {
        // Log.d( TAG, String.format( "Tapped at a (x,y) (%d,%d)", tappedPoint.x, tappedPoint.y ) );
        tappedUri.add(media.uri);
      }
    }
    if (tappedUri.size() > 0) {
      return handleMediaTapList(tappedUri);
    } else {
      if (mTrackColoringMethod == DRAW_DOTS) {
        DotVO tapped = null;
        synchronized (mDotPath) // Switch the fresh path with the old Path object
        {
          int w = 25;
          for (DotVO dot : mDotPath) {
            //                  Log.d( TAG, "Compare ("+dot.x+","+dot.y+") with tap
            // ("+tappedPoint.x+","+tappedPoint.y+")" );
            if (dot.x - w < tappedPoint.x
                && tappedPoint.x < dot.x + w
                && dot.y - w < tappedPoint.y
                && tappedPoint.y < dot.y + w) {
              if (tapped == null) {
                tapped = dot;
              } else {
                tapped =
                    dot.distanceTo(tappedPoint) < tapped.distanceTo(tappedPoint) ? dot : tapped;
              }
            }
          }
        }
        if (tapped != null) {
          DateFormat timeFormat =
              android.text.format.DateFormat.getTimeFormat(mLoggerMap.getApplicationContext());
          String timetxt = timeFormat.format(new Date(tapped.time));
          UnitsI18n units = new UnitsI18n(mLoggerMap, null);
          double speed = units.conversionFromMetersPerSecond(tapped.speed);
          String speedtxt = String.format("%.1f %s", speed, units.getSpeedUnit());
          String text = mLoggerMap.getString(R.string.time_and_speed, timetxt, speedtxt);
          Toast toast = Toast.makeText(mLoggerMap, text, Toast.LENGTH_SHORT);
          toast.show();
        }
      }
      return false;
    }
  }
  private void drawTrackingStatistics() {
    calculating = true;
    String overallavgSpeedText = "Unknown";
    String avgSpeedText = "Unknown";
    String maxSpeedText = "Unknown";
    String maxAltitudeText = "Unknown";
    String minAltitudeText = "Unknown";
    String tracknameText = "Unknown";
    String waypointsText = "Unknown";
    String distanceText = "Unknown";
    long starttime = 0;
    long endtime = 0;
    double maxSpeeddb = 0;
    double maxAltitude = 0;
    double minAltitude = 0;
    double distanceTraveled = 0f;
    long duration = 1;
    long overallduration = 1;

    ContentResolver resolver = this.getApplicationContext().getContentResolver();

    Cursor waypointsCursor = null;
    try {
      waypointsCursor =
          resolver.query(
              Uri.withAppendedPath(mTrackUri, "waypoints"),
              new String[] {
                "max  (" + Waypoints.TABLE + "." + Waypoints.SPEED + ")",
                "max  (" + Waypoints.TABLE + "." + Waypoints.ALTITUDE + ")",
                "min  (" + Waypoints.TABLE + "." + Waypoints.ALTITUDE + ")",
                "count(" + Waypoints.TABLE + "." + Waypoints._ID + ")"
              },
              null,
              null,
              null);
      if (waypointsCursor.moveToLast()) {
        maxSpeeddb = waypointsCursor.getDouble(0);
        maxAltitude = waypointsCursor.getDouble(1);
        minAltitude = waypointsCursor.getDouble(2);
        long nrWaypoints = waypointsCursor.getLong(3);
        waypointsText = nrWaypoints + "";
      }
    } finally {
      if (waypointsCursor != null) {
        waypointsCursor.close();
      }
    }
    Cursor trackCursor = null;
    try {
      trackCursor = resolver.query(mTrackUri, new String[] {Tracks.NAME}, null, null, null);
      if (trackCursor.moveToLast()) {
        tracknameText = trackCursor.getString(0);
      }
    } finally {
      if (trackCursor != null) {
        trackCursor.close();
      }
    }
    Cursor segments = null;
    Location lastLocation = null;
    Location currentLocation = null;
    try {
      Uri segmentsUri = Uri.withAppendedPath(this.mTrackUri, "segments");
      segments = resolver.query(segmentsUri, new String[] {Segments._ID}, null, null, null);
      if (segments.moveToFirst()) {
        do {
          long segmentsId = segments.getLong(0);
          Cursor waypoints = null;
          try {
            Uri waypointsUri = Uri.withAppendedPath(segmentsUri, segmentsId + "/waypoints");
            waypoints =
                resolver.query(
                    waypointsUri,
                    new String[] {
                      Waypoints._ID, Waypoints.TIME, Waypoints.LONGITUDE, Waypoints.LATITUDE
                    },
                    null,
                    null,
                    null);
            if (waypoints.moveToFirst()) {
              do {
                if (starttime == 0) {
                  starttime = waypoints.getLong(1);
                }
                currentLocation = new Location(this.getClass().getName());
                currentLocation.setTime(waypoints.getLong(1));
                currentLocation.setLongitude(waypoints.getDouble(2));
                currentLocation.setLatitude(waypoints.getDouble(3));
                if (lastLocation != null) {
                  distanceTraveled += lastLocation.distanceTo(currentLocation);
                  duration += currentLocation.getTime() - lastLocation.getTime();
                }
                lastLocation = currentLocation;

              } while (waypoints.moveToNext());
              endtime = lastLocation.getTime();
              overallduration = endtime - starttime;
            }
          } finally {
            if (waypoints != null) {
              waypoints.close();
            }
          }
          lastLocation = null;
        } while (segments.moveToNext());
      }
    } finally {
      if (segments != null) {
        segments.close();
      }
    }

    mGraphView.setData(
        mTrackUri,
        starttime,
        endtime,
        distanceTraveled,
        minAltitude,
        maxAltitude,
        maxSpeeddb,
        mUnits);

    maxSpeeddb = mUnits.conversionFromMetersPerSecond(maxSpeeddb);
    maxAltitude = mUnits.conversionFromMeterToSmall(maxAltitude);
    minAltitude = mUnits.conversionFromMeterToSmall(minAltitude);
    double overallavgSpeedfl =
        mUnits.conversionFromMeterAndMiliseconds(distanceTraveled, overallduration);
    double avgSpeedfl = mUnits.conversionFromMeterAndMiliseconds(distanceTraveled, duration);
    distanceTraveled = mUnits.conversionFromMeter(distanceTraveled);
    avgSpeedText = String.format("%.2f %s", avgSpeedfl, mUnits.getSpeedUnit());
    overallavgSpeedText = String.format("%.2f %s", overallavgSpeedfl, mUnits.getSpeedUnit());
    distanceText = String.format("%.2f %s", distanceTraveled, mUnits.getDistanceUnit());
    maxSpeedText = String.format("%.2f %s", maxSpeeddb, mUnits.getSpeedUnit());
    minAltitudeText = String.format("%.0f %s", minAltitude, mUnits.getDistanceSmallUnit());
    maxAltitudeText = String.format("%.0f %s", maxAltitude, mUnits.getDistanceSmallUnit());

    maxSpeedView.setText(maxSpeedText);
    maxAltitudeView.setText(maxAltitudeText);
    minAltitudeView.setText(minAltitudeText);
    overallavgSpeedView.setText(overallavgSpeedText);
    avgSpeedView.setText(avgSpeedText);
    distanceView.setText(distanceText);
    starttimeView.setText(Long.toString(starttime));
    endtimeView.setText(Long.toString(endtime));
    String titleFormat = getString(R.string.stat_title);
    setTitle(String.format(titleFormat, tracknameText));
    waypointsView.setText(waypointsText);

    calculating = false;
  }