diff --git a/MyTracks/AndroidManifest.xml b/MyTracks/AndroidManifest.xml index 578bd1e48..d5a7c09ca 100755 --- a/MyTracks/AndroidManifest.xml +++ b/MyTracks/AndroidManifest.xml @@ -158,10 +158,12 @@ limitations under the License. + + diff --git a/MyTracks/res/layout/about.xml b/MyTracks/res/layout/about.xml index 51f432b90..753d860e8 100644 --- a/MyTracks/res/layout/about.xml +++ b/MyTracks/res/layout/about.xml @@ -58,6 +58,11 @@ limitations under the License. android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical"> + Wersja: Wsparcie Wsparcie: + + Bartłomiej Niechwiej Wyślij do... diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index b837dcc82..c2d8886e9 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -388,6 +388,7 @@ limitations under the License. mytracks@googlegroups.com mytracks.appspot.com Copyright 2009 Google Inc. + Bartlomiej Niechwiej Dylan Casey Leif Hendrik Wilden Rodrigo Damazio Bovendorp diff --git a/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java b/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java index 56c70db13..f0839180e 100644 --- a/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java +++ b/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java @@ -21,6 +21,7 @@ import android.database.Cursor; import android.location.Location; import android.net.Uri; +import java.util.Iterator; import java.util.List; /** @@ -309,6 +310,71 @@ public interface MyTracksProviderUtils { * @return a new waypoint object */ Waypoint createWaypoint(Cursor cursor); + + /** + * A lightweight wrapper around the original {@link Cursor} with a method to clean up. + */ + interface LocationIterator extends Iterator { + /** + * Should be called in case the underlying iterator hasn't reached the last record. + */ + void close(); + } + + /** + * A factory for creating new {@class Location}s. + */ + interface LocationFactory { + /** + * Creates a new {@link Location} object to be populated from the underlying database record. + * It's up to the implementing class to decide whether to create a new instance or reuse + * existing to optimize for speed. + * + * @return a {@link Location} to be populated from the database. + */ + Location createLocation(); + } + + /** + * The default {@class Location}s factory, which creates a new location of 'gps' type each + * time the user advances to the next element using {@link LocationIterator#next()} method. + */ + LocationFactory DEFAULT_LOCATION_FACTORY = new LocationFactory() { + @Override + public Location createLocation() { + return new Location("gps"); + } + }; + + /** + * Creates a new read-only iterator over all track points for the given track. It provides + * a lightweight way of iterating over large tracks without failing due to the underlying cursor + * limitations. Since it's a read-only iterator, {@link Iterator#remove()} always throws + * {@class UnsupportedOperationException}. + * + * Once constructed, the user should either iterate over all elements, or call + * {@link LocationIterator#close()} to make sure that all resources are properly deallocated. + * + * Example use: + * + * ... + * LocationIterator it = providerUtils.getLocationIterator( + * 1, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY); + * try { + * for (Location loc : it) { + * ... // Do something useful with the location. + * } + * } finally { + * it.close(); + * } + * ... + * + * + * @param trackId the ID of a track to retrieve locations for. + * @param locationFactory the factory for creating new locations. + * @return the read-only iterator over the given track's points. + */ + LocationIterator getLocationIterator(long trackId, LocationFactory locationFactory); /** * A factory which can produce instances of {@link MyTracksProviderUtils}, diff --git a/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtilsImpl.java b/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtilsImpl.java index f9e466dce..c81bf88d3 100644 --- a/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtilsImpl.java +++ b/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtilsImpl.java @@ -934,4 +934,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils { contentResolver.update(TracksColumns.CONTENT_URI, createContentValues(track), "_id=" + track.getId(), null); } + + @Override + public LocationIterator getLocationIterator(long trackId, LocationFactory locationFactory) { + // TODO: Implement it. + throw new UnsupportedOperationException(); + } }