mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-04 18:43:07 +02:00
Merge heads
This commit is contained in:
@@ -129,6 +129,15 @@ public interface MyTracksProviderUtils {
|
||||
*/
|
||||
long getLastWaypointId(long trackId);
|
||||
|
||||
/**
|
||||
* Gets the next marker number.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param statistics true for statistics marker, false for waypoint marker
|
||||
* @return the next number or -1 if unable to get the value
|
||||
*/
|
||||
int getNextMarkerNumber(long trackId, boolean statistics);
|
||||
|
||||
/**
|
||||
* Finds the last recorded track from the track provider.
|
||||
*
|
||||
|
||||
+31
@@ -794,6 +794,37 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextMarkerNumber(long trackId, boolean statistics) {
|
||||
if (trackId == -1L) {
|
||||
return -1;
|
||||
}
|
||||
String[] projection = { "_id" };
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||
String[] selectionArgs = new String[] { String.valueOf(trackId),
|
||||
String.valueOf(statistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT) };
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = contentResolver.query(
|
||||
WaypointsColumns.CONTENT_URI, projection, selection, selectionArgs, null);
|
||||
if (cursor != null) {
|
||||
int count = cursor.getCount();
|
||||
/*
|
||||
* For statistics markers, the first marker is for the track statistics,
|
||||
* thus just return the count as the next user visible number.
|
||||
*/
|
||||
return statistics ? count : count + 1;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Caught unexpected exception.", e);
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Track getLastTrack() {
|
||||
Cursor cursor = null;
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ import android.os.Parcelable;
|
||||
public class WaypointCreationRequest implements Parcelable {
|
||||
|
||||
public static enum WaypointType {
|
||||
MARKER,
|
||||
WAYPOINT,
|
||||
STATISTICS;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class WaypointCreationRequest implements Parcelable {
|
||||
private String description;
|
||||
private String iconUrl;
|
||||
|
||||
public final static WaypointCreationRequest DEFAULT_MARKER =
|
||||
new WaypointCreationRequest(WaypointType.MARKER);
|
||||
public final static WaypointCreationRequest DEFAULT_WAYPOINT =
|
||||
new WaypointCreationRequest(WaypointType.WAYPOINT);
|
||||
public final static WaypointCreationRequest DEFAULT_STATISTICS =
|
||||
new WaypointCreationRequest(WaypointType.STATISTICS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user