mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-11 05:23:07 +02:00
Find track by UUID.
This commit is contained in:
@@ -30,6 +30,7 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.BuildConfig;
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
import de.dennisguse.opentracks.android.ContentResolverWrapper;
|
import de.dennisguse.opentracks.android.ContentResolverWrapper;
|
||||||
@@ -205,11 +206,6 @@ public class ContentProviderUtils {
|
|||||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?", new String[]{Long.toString(trackId)});
|
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?", new String[]{Long.toString(trackId)});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all the tracks.
|
|
||||||
*
|
|
||||||
* @return the tracks do not have any trackPoints attached.
|
|
||||||
*/
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public List<Track> getAllTracks() {
|
public List<Track> getAllTracks() {
|
||||||
ArrayList<Track> tracks = new ArrayList<>();
|
ArrayList<Track> tracks = new ArrayList<>();
|
||||||
@@ -236,7 +232,6 @@ public class ContentProviderUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param trackId the track id.
|
* @param trackId the track id.
|
||||||
* @return the track doesn't have any trackPoints attached
|
|
||||||
*/
|
*/
|
||||||
public Track getTrack(long trackId) {
|
public Track getTrack(long trackId) {
|
||||||
if (trackId < 0) {
|
if (trackId < 0) {
|
||||||
@@ -250,6 +245,18 @@ public class ContentProviderUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uuid the UUID of a track.
|
||||||
|
*/
|
||||||
|
public Track getTrack(UUID uuid) {
|
||||||
|
try (Cursor cursor = getTrackCursor(TracksColumns.UUID + "=?", new String[]{uuid.toString()}, TracksColumns._ID)) {
|
||||||
|
if (cursor != null && cursor.moveToNext()) {
|
||||||
|
return createTrack(cursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a track cursor.
|
* Gets a track cursor.
|
||||||
* The caller owns the returned cursor and is responsible for closing it.
|
* The caller owns the returned cursor and is responsible for closing it.
|
||||||
|
|||||||
Reference in New Issue
Block a user