Get activity title from uploaded file, if it is present #7
2 changed files with 8 additions and 3 deletions
|
|
@ -26,6 +26,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static net.javahippie.fitpub.util.ParsedActivityData.MAX_TITLE_LENGTH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser for GPX (GPS Exchange Format) files.
|
* Parser for GPX (GPS Exchange Format) files.
|
||||||
* Extracts GPS coordinates, activity metrics from track points.
|
* Extracts GPS coordinates, activity metrics from track points.
|
||||||
|
|
@ -280,9 +282,9 @@ public class GpxParser {
|
||||||
String title = getElementText(track, "name");
|
String title = getElementText(track, "name");
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
String shortenedTitle = title;
|
String shortenedTitle = title;
|
||||||
if (title.length() > 255) {
|
if (title.length() > MAX_TITLE_LENGTH) {
|
||||||
log.debug("Activity title was shortened to 255 characters: {}", title);
|
log.debug("Activity title was shortened to {} characters: {}", MAX_TITLE_LENGTH, title);
|
||||||
shortenedTitle = title.substring(0, 255);
|
shortenedTitle = title.substring(0, MAX_TITLE_LENGTH);
|
||||||
}
|
}
|
||||||
parsedData.setTitle(shortenedTitle);
|
parsedData.setTitle(shortenedTitle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ParsedActivityData {
|
public class ParsedActivityData {
|
||||||
|
|
||||||
|
static final int MAX_TITLE_LENGTH = 255;
|
||||||
|
|
||||||
private List<TrackPointData> trackPoints = new ArrayList<>();
|
private List<TrackPointData> trackPoints = new ArrayList<>();
|
||||||
private LocalDateTime startTime;
|
private LocalDateTime startTime;
|
||||||
private LocalDateTime endTime;
|
private LocalDateTime endTime;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue