forked from upstream-mirrors/OpenTracks
Cleanup: use ActivityType instead of passing it's id around as String.
Part of #1608.
This commit is contained in:
@@ -34,22 +34,22 @@ public enum ActivityType {
|
||||
SWIMMING_OPEN("SWIMMING_OPEN", R.drawable.ic_activity_swimming_open_24dp, false, R.string.activity_type_swimming_open),
|
||||
WORKOUT("WORKOUT", R.drawable.ic_activity_workout_24dp, false, R.string.activity_type_workout);
|
||||
|
||||
final String id;
|
||||
final String iconId;
|
||||
final int iconDrawableId;
|
||||
final boolean showSpeedPreferred;
|
||||
final int[] localizedStringIds;
|
||||
|
||||
//isSpeed?
|
||||
|
||||
ActivityType(String id, int iconDrawableId, boolean showSpeedPreferred, int... localizedStringIds) {
|
||||
this.id = id;
|
||||
ActivityType(String iconId, int iconDrawableId, boolean showSpeedPreferred, int... localizedStringIds) {
|
||||
this.iconId = iconId;
|
||||
this.iconDrawableId = iconDrawableId;
|
||||
this.showSpeedPreferred = showSpeedPreferred;
|
||||
this.localizedStringIds = localizedStringIds;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
public String getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public int getIconDrawableId() {
|
||||
@@ -81,9 +81,9 @@ public enum ActivityType {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static ActivityType findByActivityTypeId(String activityTypeId) {
|
||||
public static ActivityType findBy(String iconId) {
|
||||
return Arrays.stream(ActivityType.values()).filter(
|
||||
it -> it.getId().equals(activityTypeId)
|
||||
it -> it.getIconId().equals(iconId)
|
||||
).findFirst()
|
||||
.orElse(ActivityType.UNKNOWN);
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ public class Track {
|
||||
|
||||
private String name = "";
|
||||
private String description = "";
|
||||
private String activityType = "";
|
||||
private String activityTypeLocalized = "";
|
||||
|
||||
private String activityTypeId = "";
|
||||
private ActivityType activityType;
|
||||
|
||||
private final ZoneOffset zoneOffset;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Track {
|
||||
|
||||
@VisibleForTesting
|
||||
public Track() {
|
||||
this.zoneOffset = ZoneOffset.UTC;
|
||||
this(ZoneOffset.UTC);
|
||||
}
|
||||
|
||||
public Track(@NonNull ZoneOffset zoneOffset) {
|
||||
@@ -97,22 +97,22 @@ public class Track {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getActivityType() {
|
||||
public String getActivityTypeLocalized() {
|
||||
return activityTypeLocalized;
|
||||
}
|
||||
|
||||
public void setActivityTypeLocalized(String activityType) {
|
||||
this.activityTypeLocalized = activityType;
|
||||
}
|
||||
|
||||
public ActivityType getActivityType() {
|
||||
return activityType;
|
||||
}
|
||||
|
||||
public void setActivityType(String activityType) {
|
||||
public void setActivityType(ActivityType activityType) {
|
||||
this.activityType = activityType;
|
||||
}
|
||||
|
||||
public String getActivityTypeId() {
|
||||
return activityTypeId;
|
||||
}
|
||||
|
||||
public void setActivityTypeId(String activityTypeId) {
|
||||
this.activityTypeId = activityTypeId;
|
||||
}
|
||||
|
||||
public ZoneOffset getZoneOffset() {
|
||||
return zoneOffset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user