/** Called when the activity is first created. */
  @Override
  protected void onCreate(Bundle load) {
    super.onCreate(load);
    mUnits =
        new UnitsI18n(
            this,
            new UnitsI18n.UnitsChangeListener() {
              public void onUnitsChange() {
                drawTrackingStatistics();
              }
            });
    setContentView(R.layout.statistics);

    mViewFlipper = (ViewFlipper) findViewById(R.id.flipper);
    mViewFlipper.setDrawingCacheEnabled(true);
    mSlideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
    mSlideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
    mSlideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
    mSlideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);

    mGraphTimeSpeed = (GraphCanvas) mViewFlipper.getChildAt(0);
    mGraphDistanceSpeed = (GraphCanvas) mViewFlipper.getChildAt(1);
    mGraphTimeAltitude = (GraphCanvas) mViewFlipper.getChildAt(2);
    mGraphDistanceAltitude = (GraphCanvas) mViewFlipper.getChildAt(3);

    mGraphTimeSpeed.setType(GraphCanvas.TIMESPEEDGRAPH);
    mGraphDistanceSpeed.setType(GraphCanvas.DISTANCESPEEDGRAPH);
    mGraphTimeAltitude.setType(GraphCanvas.TIMEALTITUDEGRAPH);
    mGraphDistanceAltitude.setType(GraphCanvas.DISTANCEALTITUDEGRAPH);

    mGestureDetector = new GestureDetector(new MyGestureDetector());

    maxSpeedView = (TextView) findViewById(R.id.stat_maximumspeed);
    mAscensionView = (TextView) findViewById(R.id.stat_ascension);
    mElapsedTimeView = (TextView) findViewById(R.id.stat_elapsedtime);
    overallavgSpeedView = (TextView) findViewById(R.id.stat_overallaveragespeed);
    avgSpeedView = (TextView) findViewById(R.id.stat_averagespeed);
    distanceView = (TextView) findViewById(R.id.stat_distance);
    starttimeView = (TextView) findViewById(R.id.stat_starttime);
    endtimeView = (TextView) findViewById(R.id.stat_endtime);
    waypointsView = (TextView) findViewById(R.id.stat_waypoints);

    if (load != null && load.containsKey(TRACKURI)) {
      mTrackUri = Uri.withAppendedPath(Tracks.CONTENT_URI, load.getString(TRACKURI));
    } else {
      mTrackUri = this.getIntent().getData();
    }
  }
 public void onClick(View v) {
   int id = v.getId();
   switch (id) {
     case R.id.graphtype_distancealtitude:
       mGraphView.setType(GraphCanvas.DISTANCEALTITUDEGRAPH);
       break;
     case R.id.graphtype_distancespeed:
       mGraphView.setType(GraphCanvas.DISTANCESPEEDGRAPH);
       break;
     case R.id.graphtype_timealtitude:
       mGraphView.setType(GraphCanvas.TIMEALTITUDEGRAPH);
       break;
     case R.id.graphtype_timespeed:
       mGraphView.setType(GraphCanvas.TIMESPEEDGRAPH);
       break;
     default:
       break;
   }
   dismissDialog(DIALOG_GRAPHTYPE);
 }
 @Override
 protected void onRestoreInstanceState(Bundle load) {
   if (load != null) {
     super.onRestoreInstanceState(load);
   }
   if (load != null && load.containsKey(GRAPH_TYPE)) {
     mGraphView.setType(load.getInt(GRAPH_TYPE));
   }
   if (load != null && load.containsKey(TRACKURI)) {
     mTrackUri = Uri.withAppendedPath(Tracks.CONTENT_URI, load.getString(TRACKURI));
   }
 }