forked from upstream-mirrors/OpenTracks
Removed WaypointType.
This commit is contained in:
@@ -35,7 +35,6 @@ import java.util.NoSuchElementException;
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
import de.dennisguse.opentracks.android.ContentResolverWrapper;
|
||||
import de.dennisguse.opentracks.android.IContentResolver;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
import de.dennisguse.opentracks.stats.TripStatistics;
|
||||
import de.dennisguse.opentracks.util.FileUtils;
|
||||
@@ -443,9 +442,6 @@ public class ContentProviderUtils {
|
||||
if (!cursor.isNull(trackIdIndex)) {
|
||||
waypoint.setTrackId(cursor.getLong(trackIdIndex));
|
||||
}
|
||||
if (!cursor.isNull(typeIndex)) {
|
||||
waypoint.setType(WaypointType.values()[cursor.getInt(typeIndex)]);
|
||||
}
|
||||
if (!cursor.isNull(lengthIndex)) {
|
||||
waypoint.setLength(cursor.getFloat(lengthIndex));
|
||||
}
|
||||
@@ -539,25 +535,10 @@ public class ContentProviderUtils {
|
||||
* The generator is used to update the next statistics waypoint.
|
||||
*
|
||||
* @param waypointId the waypoint id
|
||||
* @param descriptionGenerator the description generator. Can be null for waypoint marker
|
||||
*/
|
||||
|
||||
public void deleteWaypoint(Context context, long waypointId, DescriptionGenerator descriptionGenerator) {
|
||||
public void deleteWaypoint(Context context, long waypointId) {
|
||||
final Waypoint waypoint = getWaypoint(waypointId);
|
||||
if (waypoint != null && waypoint.getType() == WaypointType.STATISTICS
|
||||
&& descriptionGenerator != null) {
|
||||
final Waypoint nextWaypoint = getNextStatisticsWaypointAfter(waypoint);
|
||||
if (nextWaypoint == null) {
|
||||
Log.d(TAG, "Unable to find the next statistics marker after deleting one.");
|
||||
} else {
|
||||
nextWaypoint.getTripStatistics().merge(waypoint.getTripStatistics());
|
||||
nextWaypoint.setDescription(
|
||||
descriptionGenerator.generateWaypointDescription(nextWaypoint.getTripStatistics()));
|
||||
if (!updateWaypoint(nextWaypoint)) {
|
||||
Log.e(TAG, "Unable to update the next statistics marker after deleting one.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (waypoint != null && waypoint.hasPhoto()) {
|
||||
Uri uri = waypoint.getPhotoURI();
|
||||
File file = new File(uri.getPath());
|
||||
@@ -596,14 +577,13 @@ public class ContentProviderUtils {
|
||||
* Gets the last waypoint for a type. Returns null if it doesn't exist.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param waypointType the waypoint type
|
||||
*/
|
||||
public Waypoint getLastWaypoint(long trackId, WaypointType waypointType) {
|
||||
public Waypoint getLastWaypoint(long trackId) {
|
||||
if (trackId < 0) {
|
||||
return null;
|
||||
}
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId), Integer.toString(waypointType.ordinal())};
|
||||
String selection = WaypointsColumns.TRACKID + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId)};
|
||||
try (Cursor cursor = getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID + " DESC", 1)) {
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
@@ -618,20 +598,17 @@ public class ContentProviderUtils {
|
||||
* Returns -1 if not able to get the next waypoint number.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param waypointType the waypoint type
|
||||
*/
|
||||
public int getNextWaypointNumber(long trackId, WaypointType waypointType) {
|
||||
public int getNextWaypointNumber(long trackId) {
|
||||
if (trackId < 0) {
|
||||
return -1;
|
||||
}
|
||||
String[] projection = {WaypointsColumns._ID};
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId), Integer.toString(waypointType.ordinal())};
|
||||
String selection = WaypointsColumns.TRACKID + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId)};
|
||||
try (Cursor cursor = getWaypointCursor(projection, selection, selectionArgs, WaypointsColumns._ID, -1)) {
|
||||
if (cursor != null) {
|
||||
int count = cursor.getCount();
|
||||
// For statistics markers, the first marker is for the track statistics, so return the count as the next user visible number.
|
||||
return waypointType == WaypointType.STATISTICS ? count : count + 1;
|
||||
return cursor.getCount();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -751,7 +728,6 @@ public class ContentProviderUtils {
|
||||
values.put(WaypointsColumns.CATEGORY, waypoint.getCategory());
|
||||
values.put(WaypointsColumns.ICON, waypoint.getIcon());
|
||||
values.put(WaypointsColumns.TRACKID, waypoint.getTrackId());
|
||||
values.put(WaypointsColumns.TYPE, waypoint.getType().ordinal());
|
||||
values.put(WaypointsColumns.LENGTH, waypoint.getLength());
|
||||
values.put(WaypointsColumns.DURATION, waypoint.getDuration());
|
||||
values.put(WaypointsColumns.STARTID, waypoint.getStartId());
|
||||
@@ -796,18 +772,6 @@ public class ContentProviderUtils {
|
||||
return values;
|
||||
}
|
||||
|
||||
private Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint) {
|
||||
String selection = WaypointsColumns._ID + ">? AND " + WaypointsColumns.TRACKID + "=? AND "
|
||||
+ WaypointsColumns.TYPE + "=" + WaypointType.STATISTICS.ordinal();
|
||||
String[] selectionArgs = new String[]{Long.toString(waypoint.getId()), Long.toString(waypoint.getTrackId())};
|
||||
try (Cursor cursor = getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID, 1)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return createWaypoint(cursor);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a waypoint cursor.
|
||||
*
|
||||
|
||||
@@ -35,7 +35,6 @@ public final class Waypoint {
|
||||
private String category = "";
|
||||
private String icon = "";
|
||||
private long trackId = -1L;
|
||||
private WaypointType type = WaypointType.WAYPOINT;
|
||||
private double length = 0.0;
|
||||
private long duration = 0;
|
||||
private long startId = -1L;
|
||||
@@ -47,13 +46,12 @@ public final class Waypoint {
|
||||
public Waypoint() {
|
||||
}
|
||||
|
||||
public Waypoint(String name, String description, String category, String icon, long trackId, WaypointType type, double length, long duration, long startId, long stopId, Location location, TripStatistics tripStatistics, String photoUrl) {
|
||||
public Waypoint(String name, String description, String category, String icon, long trackId, double length, long duration, long startId, long stopId, Location location, TripStatistics tripStatistics, String photoUrl) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.icon = icon;
|
||||
this.trackId = trackId;
|
||||
this.type = type;
|
||||
this.length = length;
|
||||
this.duration = duration;
|
||||
this.startId = startId;
|
||||
@@ -111,14 +109,6 @@ public final class Waypoint {
|
||||
this.trackId = trackId;
|
||||
}
|
||||
|
||||
public WaypointType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WaypointType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getLength() {
|
||||
return length;
|
||||
}
|
||||
@@ -186,9 +176,4 @@ public final class Waypoint {
|
||||
public boolean hasPhoto() {
|
||||
return photoUrl != null && !"".equals(photoUrl);
|
||||
}
|
||||
|
||||
public enum WaypointType {
|
||||
WAYPOINT,
|
||||
STATISTICS //Always the first waypoint; only one can exist.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package de.dennisguse.opentracks.content;
|
||||
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
|
||||
/**
|
||||
* A request for the service to create a waypoint at the current location.
|
||||
@@ -24,12 +23,10 @@ import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
*/
|
||||
public class WaypointCreationRequest {
|
||||
|
||||
public final static WaypointCreationRequest DEFAULT_WAYPOINT = new WaypointCreationRequest(WaypointType.WAYPOINT, false);
|
||||
public final static WaypointCreationRequest DEFAULT_WAYPOINT = new WaypointCreationRequest(false);
|
||||
|
||||
@Deprecated // TODO Do not create per
|
||||
public final static WaypointCreationRequest DEFAULT_START_TRACK = new WaypointCreationRequest(WaypointType.STATISTICS, true);
|
||||
|
||||
private WaypointType type;
|
||||
public final static WaypointCreationRequest DEFAULT_START_TRACK = new WaypointCreationRequest(true);
|
||||
|
||||
// true if this marker contains the track statistics
|
||||
private boolean isTrackStatistics;
|
||||
@@ -40,12 +37,11 @@ public class WaypointCreationRequest {
|
||||
private String iconUrl;
|
||||
private String photoUrl;
|
||||
|
||||
private WaypointCreationRequest(WaypointType type, boolean isTrackStatistics) {
|
||||
this(type, isTrackStatistics, null, null, null, null, null);
|
||||
private WaypointCreationRequest(boolean isTrackStatistics) {
|
||||
this(isTrackStatistics, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public WaypointCreationRequest(WaypointType type, boolean isTrackStatistics, String name, String category, String description, String iconUrl, String photoUrl) {
|
||||
this.type = type;
|
||||
public WaypointCreationRequest(boolean isTrackStatistics, String name, String category, String description, String iconUrl, String photoUrl) {
|
||||
this.isTrackStatistics = isTrackStatistics;
|
||||
this.name = name;
|
||||
this.category = category;
|
||||
@@ -54,10 +50,6 @@ public class WaypointCreationRequest {
|
||||
this.photoUrl = photoUrl;
|
||||
}
|
||||
|
||||
public WaypointType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isTrackStatistics() {
|
||||
return isTrackStatistics;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user