diff --git a/MyTracks/src/com/google/android/apps/mytracks/Constants.java b/MyTracks/src/com/google/android/apps/mytracks/Constants.java index 55be941db..8c70535fe 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/Constants.java +++ b/MyTracks/src/com/google/android/apps/mytracks/Constants.java @@ -30,17 +30,6 @@ public class Constants { */ public static final String ACCOUNT_TYPE = "com.google"; - /** - * Maximum number of track points displayed by the map overlay. Set to 2X of - * {@link Constants#TARGET_DISPLAYED_TRACK_POINTS} - */ - public static final int MAX_DISPLAYED_TRACK_POINTS = 10000; - - /** - * Maximum number of waypoints displayed by the map overlay. - */ - public static final int MAX_DISPLAYED_WAYPOINTS_POINTS = 128; - /** * Maximum number of track points that will be loaded at one time. With * recording frequency of 2 seconds, 20000 corresponds to 11.1 hours. @@ -56,10 +45,4 @@ public class Constants { * The settings file name. */ public static final String SETTINGS_NAME = "SettingsActivity"; - - /** - * Target number of track points displayed by the map overlay. We may display - * more than this number of points. - */ - public static final int TARGET_DISPLAYED_TRACK_POINTS = 5000; } diff --git a/MyTracks/src/com/google/android/apps/mytracks/MapOverlay.java b/MyTracks/src/com/google/android/apps/mytracks/MapOverlay.java index 16498ec60..5fbb31eb7 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MapOverlay.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MapOverlay.java @@ -16,6 +16,8 @@ package com.google.android.apps.mytracks; +import static com.google.android.apps.mytracks.content.TrackDataHub.TARGET_DISPLAYED_TRACK_POINTS; + import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint.WaypointType; import com.google.android.apps.mytracks.maps.TrackPath; @@ -138,8 +140,10 @@ public class MapOverlay { this.context = context; this.waypoints = new ArrayList(); this.locations = new ArrayList(INITIAL_LOCATIONS_SIZE); + + // Set the number of points to be 2x the TARGET_DISPLAYED_TRACK_POINTS this.pendingLocations = new ArrayBlockingQueue( - Constants.MAX_DISPLAYED_TRACK_POINTS, true); + 2 * TARGET_DISPLAYED_TRACK_POINTS, true); context.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE) .registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); diff --git a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java index c15a75543..c3013db26 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java +++ b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java @@ -16,10 +16,6 @@ package com.google.android.apps.mytracks.content; -import static com.google.android.apps.mytracks.Constants.MAX_DISPLAYED_WAYPOINTS_POINTS; -import static com.google.android.apps.mytracks.Constants.TARGET_DISPLAYED_TRACK_POINTS; - -import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator; import com.google.android.apps.mytracks.util.LocationUtils; import com.google.android.apps.mytracks.util.PreferencesUtils; @@ -47,6 +43,18 @@ public class TrackDataHub implements DataSourceListener { private static final String TAG = TrackDataHub.class.getSimpleName(); + /** + * Maximum number of waypoints to displayed. + */ + @VisibleForTesting + static final int MAX_DISPLAYED_WAYPOINTS = 128; + + /** + * Target number of track points displayed by the map overlay. We may display + * more than this number of points. + */ + public static final int TARGET_DISPLAYED_TRACK_POINTS = 5000; + private final Context context; private final TrackDataManager trackDataManager; private final MyTracksProviderUtils myTracksProviderUtils; @@ -415,8 +423,8 @@ public class TrackDataHub implements DataSourceListener { /** * Notifies waypoint table update. Currently, reloads all the waypoints up to - * {@link Constants#MAX_DISPLAYED_WAYPOINTS_POINTS}. To be run in the - * {@link #handler} thread. + * {@link #MAX_DISPLAYED_WAYPOINTS}. To be run in the {@link #handler} + * thread. * * @param trackDataListeners the track data listeners to notify */ @@ -432,7 +440,7 @@ public class TrackDataHub implements DataSourceListener { Cursor cursor = null; try { cursor = myTracksProviderUtils.getWaypointCursor( - selectedTrackId, -1L, MAX_DISPLAYED_WAYPOINTS_POINTS); + selectedTrackId, -1L, MAX_DISPLAYED_WAYPOINTS); if (cursor != null && cursor.moveToFirst()) { do { Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor); diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/content/TrackDataHubTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/content/TrackDataHubTest.java index 86e9cee75..77afab70a 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/content/TrackDataHubTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/content/TrackDataHubTest.java @@ -187,7 +187,7 @@ public class TrackDataHubTest extends AndroidTestCase { // Register two listeners Capture contentObserverCapture = new Capture(); expect(myTracksProviderUtils.getWaypointCursor( - eq(TRACK_ID), AndroidMock.leq(-1L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS))) + eq(TRACK_ID), AndroidMock.leq(-1L), eq(TrackDataHub.MAX_DISPLAYED_WAYPOINTS))) .andStubAnswer(new FixedSizeCursorAnswer(2)); expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class))) .andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint1).andReturn(waypoint2); @@ -214,7 +214,7 @@ public class TrackDataHubTest extends AndroidTestCase { // Cause waypoints table update ContentObserver contentObserver = contentObserverCapture.getValue(); expect(myTracksProviderUtils.getWaypointCursor( - eq(TRACK_ID), AndroidMock.leq(-1L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS))) + eq(TRACK_ID), AndroidMock.leq(-1L), eq(TrackDataHub.MAX_DISPLAYED_WAYPOINTS))) .andStubAnswer(new FixedSizeCursorAnswer(3)); expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class))) .andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint3); @@ -235,7 +235,7 @@ public class TrackDataHubTest extends AndroidTestCase { // Unregister one listener expect(myTracksProviderUtils.getWaypointCursor( - eq(TRACK_ID), AndroidMock.leq(-1L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS))) + eq(TRACK_ID), AndroidMock.leq(-1L), eq(TrackDataHub.MAX_DISPLAYED_WAYPOINTS))) .andStubAnswer(new FixedSizeCursorAnswer(4)); expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class))) .andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint3).andReturn(waypoint4);