2018-06-14 18:16:49 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip;
|
2017-10-31 23:39:49 +01:00
|
|
|
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
|
|
|
|
|
|
|
public enum BipActivityType {
|
2017-11-05 00:08:39 +01:00
|
|
|
Outdoor(1),
|
2017-11-01 20:02:30 +01:00
|
|
|
Treadmill(2),
|
2017-11-05 00:08:39 +01:00
|
|
|
Walking(3),
|
|
|
|
Cycling(4);
|
2017-11-01 20:02:30 +01:00
|
|
|
|
|
|
|
private final int code;
|
|
|
|
|
|
|
|
BipActivityType(final int code) {
|
|
|
|
this.code = code;
|
|
|
|
}
|
2017-10-31 23:39:49 +01:00
|
|
|
|
|
|
|
public int toActivityKind() {
|
|
|
|
switch (this) {
|
|
|
|
case Outdoor:
|
|
|
|
return ActivityKind.TYPE_RUNNING;
|
|
|
|
case Treadmill:
|
|
|
|
return ActivityKind.TYPE_TREADMILL;
|
|
|
|
case Cycling:
|
|
|
|
return ActivityKind.TYPE_CYCLING;
|
|
|
|
case Walking:
|
|
|
|
return ActivityKind.TYPE_WALKING;
|
|
|
|
}
|
|
|
|
throw new RuntimeException("Not mapped activity kind for: " + this);
|
|
|
|
}
|
|
|
|
|
2017-11-01 20:02:30 +01:00
|
|
|
public static BipActivityType fromCode(int bipCode) {
|
|
|
|
for (BipActivityType type : values()) {
|
|
|
|
if (type.code == bipCode) {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new RuntimeException("No matching BipActivityType for code: " + bipCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BipActivityType fromActivityKind(int activityKind) {
|
|
|
|
switch (activityKind) {
|
2017-10-31 23:39:49 +01:00
|
|
|
case ActivityKind.TYPE_RUNNING:
|
|
|
|
return Outdoor;
|
|
|
|
case ActivityKind.TYPE_TREADMILL:
|
|
|
|
return Treadmill;
|
|
|
|
case ActivityKind.TYPE_CYCLING:
|
|
|
|
return Cycling;
|
|
|
|
case ActivityKind.TYPE_WALKING:
|
|
|
|
return Walking;
|
|
|
|
}
|
2017-11-01 20:02:30 +01:00
|
|
|
throw new RuntimeException("No matching activity activityKind: " + activityKind);
|
2017-10-31 23:39:49 +01:00
|
|
|
}
|
|
|
|
}
|