// Copyright 2011 Google Inc. All Rights Reserved.

package com.google.android.apps.mytracks;

import com.google.android.apps.mytracks.content.TrackDataHub;

import android.app.Application;

/**
 * MyTracksApplication for keeping global state.
 * 
 * @author jshih@google.com (Jimmy Shih)
 *
 */
public class MyTracksApplication extends Application {
  private TrackDataHub trackDataHub;

  /**
   * Gets the application's TrackDataHub.
   * 
   */
  public TrackDataHub getTrackDataHub() {
    if (trackDataHub == null) {     
      trackDataHub = TrackDataHub.newInstance(getApplicationContext());
    }
    return trackDataHub;
  }
  
  public void clearTrackDataHub() {
    trackDataHub = null;
  }
}

@@ -1,10 +1,13 @@
 /
-/
+*%0A *
  Copyrig
@@ -15,10 +15,10 @@
 t 20
-11
+08
  Goo
@@ -29,30 +29,566 @@
 Inc.
- All Rights Reserved.%0A
+%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not%0A * use this file except in compliance with the License. You may obtain a copy of%0A * the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and limitations under%0A * the License.%0A */
 %0Apac
@@ -778,17 +778,16 @@
 tate.%0A *
- 
 %0A * @aut
@@ -820,19 +820,16 @@
 y Shih)%0A
- *%0A
  */%0Apubl
@@ -879,16 +879,17 @@
 ation %7B%0A
+%0A
   privat
@@ -980,18 +980,118 @@
    *
-/%0A  public
+ Note: use synchronized to make sure only one instance is created per application.%0A   */%0A  public synchronized
  Tra
@@ -1151,21 +1151,16 @@
  null) %7B
-     
 %0A      t
@@ -1259,18 +1259,16 @@
 ub;%0A  %7D%0A
-  
 %0A  publi

Fix based on Sandor's comments