mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01:00
Garmin: Fallback to session for workout type
This commit is contained in:
parent
4d78fdd883
commit
aee42ec1be
@ -226,10 +226,6 @@ public class FitImporter {
|
||||
LOG.error("Got workout from {}, but no session", fileId);
|
||||
return;
|
||||
}
|
||||
if (sport == null) {
|
||||
LOG.error("Got workout from {}, but no sport", fileId);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.debug("Persisting workout for {}", fileId);
|
||||
|
||||
@ -238,32 +234,14 @@ public class FitImporter {
|
||||
|
||||
final ActivitySummaryData summaryData = new ActivitySummaryData();
|
||||
|
||||
// TODO map all sports
|
||||
if (sport.getSport() != null) {
|
||||
switch (sport.getSport()) {
|
||||
case 2:
|
||||
summary.setActivityKind(ActivityKind.TYPE_CYCLING);
|
||||
break;
|
||||
case 4: // fitness_equipment
|
||||
case 10: // training
|
||||
if (sport.getSubSport() != null) {
|
||||
switch (sport.getSubSport()) {
|
||||
case 15:
|
||||
summary.setActivityKind(ActivityKind.TYPE_ELLIPTICAL_TRAINER);
|
||||
break;
|
||||
default:
|
||||
LOG.warn("Unknown sub sport {}", sport.getSubSport());
|
||||
summaryData.add("Fit Sub Sport", sport.getSubSport(), "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG.warn("Unknown sport {}", sport.getSport());
|
||||
summaryData.add("Fit Sport", sport.getSport(), "");
|
||||
}
|
||||
final int activityKind;
|
||||
if (sport != null) {
|
||||
summary.setName(sport.getName());
|
||||
activityKind = getActivityKind(sport.getSport(), sport.getSubSport());
|
||||
} else {
|
||||
activityKind = getActivityKind(session.getSport(), session.getSubSport());
|
||||
}
|
||||
|
||||
summary.setName(sport.getName());
|
||||
summary.setActivityKind(activityKind);
|
||||
if (session.getStartTime() == null) {
|
||||
LOG.error("No session start time for {}", fileId);
|
||||
return;
|
||||
@ -322,6 +300,35 @@ public class FitImporter {
|
||||
}
|
||||
}
|
||||
|
||||
private int getActivityKind(final Integer sport, final Integer subsport) {
|
||||
// TODO map all sports
|
||||
if (sport != null) {
|
||||
switch (sport) {
|
||||
case 2:
|
||||
return ActivityKind.TYPE_CYCLING;
|
||||
case 4: // fitness_equipment
|
||||
case 10: // training
|
||||
if (subsport != null) {
|
||||
switch (subsport) {
|
||||
case 15:
|
||||
return ActivityKind.TYPE_ELLIPTICAL_TRAINER;
|
||||
case 20:
|
||||
return ActivityKind.TYPE_STRENGTH_TRAINING;
|
||||
default:
|
||||
LOG.warn("Unknown sub sport {} for {}", subsport, sport);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 11:
|
||||
return ActivityKind.TYPE_WALKING;
|
||||
default:
|
||||
LOG.warn("Unknown sport {}", sport);
|
||||
}
|
||||
}
|
||||
|
||||
return ActivityKind.TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
activitySamplesPerTimestamp.clear();
|
||||
stressSamples.clear();
|
||||
|
@ -93,6 +93,8 @@ public class GlobalFITMessage {
|
||||
new FieldDefinitionPrimitive(2, BaseType.UINT32, "start_time"),
|
||||
new FieldDefinitionPrimitive(3, BaseType.SINT32, "start_latitude"),
|
||||
new FieldDefinitionPrimitive(4, BaseType.SINT32, "start_longitude"),
|
||||
new FieldDefinitionPrimitive(5, BaseType.ENUM, "sport"),
|
||||
new FieldDefinitionPrimitive(6, BaseType.ENUM, "sub_sport"),
|
||||
new FieldDefinitionPrimitive(7, BaseType.UINT32, "total_elapsed_time"), // with pauses
|
||||
new FieldDefinitionPrimitive(8, BaseType.UINT32, "total_timer_time"), // no pauses
|
||||
new FieldDefinitionPrimitive(9, BaseType.UINT32, "total_distance"),
|
||||
|
@ -45,6 +45,16 @@ public class FitSession extends RecordData {
|
||||
return (Long) getFieldByNumber(4);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getSport() {
|
||||
return (Integer) getFieldByNumber(5);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getSubSport() {
|
||||
return (Integer) getFieldByNumber(6);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getTotalElapsedTime() {
|
||||
return (Long) getFieldByNumber(7);
|
||||
|
Loading…
Reference in New Issue
Block a user