2021-01-10 23:37:09 +01:00
|
|
|
/* Copyright (C) 2017-2021 Andreas Shimokawa, Carsten Pfeiffer
|
2018-06-25 18:35:46 +02:00
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2019-08-13 22:04:52 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami;
|
2017-10-31 23:39:49 +01:00
|
|
|
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
|
|
|
|
2019-08-13 22:04:52 +02:00
|
|
|
public enum HuamiSportsActivityType {
|
2020-09-07 21:40:20 +02:00
|
|
|
OutdoorRunning(1),
|
2017-11-01 20:02:30 +01:00
|
|
|
Treadmill(2),
|
2017-11-05 00:08:39 +01:00
|
|
|
Walking(3),
|
2019-01-28 00:22:11 +01:00
|
|
|
Cycling(4),
|
2019-08-13 22:04:52 +02:00
|
|
|
Exercise(5),
|
2020-08-16 23:45:52 +02:00
|
|
|
Swimming(6),
|
|
|
|
OpenWaterSwimming(7),
|
|
|
|
IndoorCycling(8),
|
|
|
|
EllipticalTrainer(9),
|
2020-09-07 21:40:20 +02:00
|
|
|
Soccer(0x12),
|
|
|
|
JumpRope(0x15),
|
|
|
|
RowingMachine(0x17),
|
2021-01-22 22:14:11 +01:00
|
|
|
StrengthTraining(0x34),
|
2020-09-07 21:40:20 +02:00
|
|
|
Yoga(0x3c),
|
|
|
|
Cricket(0x4e),
|
|
|
|
Basketball(0x55),
|
|
|
|
PingPong(0x59),
|
|
|
|
Badminton(0x5c);
|
|
|
|
|
2020-08-16 23:45:52 +02:00
|
|
|
|
2017-11-01 20:02:30 +01:00
|
|
|
private final int code;
|
|
|
|
|
2019-08-13 22:04:52 +02:00
|
|
|
HuamiSportsActivityType(final int code) {
|
2017-11-01 20:02:30 +01:00
|
|
|
this.code = code;
|
|
|
|
}
|
2017-10-31 23:39:49 +01:00
|
|
|
|
|
|
|
public int toActivityKind() {
|
|
|
|
switch (this) {
|
2020-09-07 21:40:20 +02:00
|
|
|
case OutdoorRunning:
|
2017-10-31 23:39:49 +01:00
|
|
|
return ActivityKind.TYPE_RUNNING;
|
|
|
|
case Treadmill:
|
|
|
|
return ActivityKind.TYPE_TREADMILL;
|
|
|
|
case Cycling:
|
|
|
|
return ActivityKind.TYPE_CYCLING;
|
|
|
|
case Walking:
|
|
|
|
return ActivityKind.TYPE_WALKING;
|
2019-01-28 00:22:11 +01:00
|
|
|
case Exercise:
|
|
|
|
return ActivityKind.TYPE_EXERCISE;
|
2019-08-13 22:04:52 +02:00
|
|
|
case Swimming:
|
|
|
|
return ActivityKind.TYPE_SWIMMING;
|
2020-08-16 23:45:52 +02:00
|
|
|
case OpenWaterSwimming:
|
|
|
|
return ActivityKind.TYPE_SWIMMING_OPENWATER;
|
|
|
|
case IndoorCycling:
|
|
|
|
return ActivityKind.TYPE_INDOOR_CYCLING;
|
|
|
|
case EllipticalTrainer:
|
|
|
|
return ActivityKind.TYPE_ELLIPTICAL_TRAINER;
|
2020-09-07 21:40:20 +02:00
|
|
|
case Soccer:
|
|
|
|
return ActivityKind.TYPE_SOCCER;
|
2020-08-16 23:45:52 +02:00
|
|
|
case JumpRope:
|
|
|
|
return ActivityKind.TYPE_JUMP_ROPING;
|
2020-09-07 21:40:20 +02:00
|
|
|
case RowingMachine:
|
|
|
|
return ActivityKind.TYPE_ROWING_MACHINE;
|
2020-08-16 23:45:52 +02:00
|
|
|
case Yoga:
|
|
|
|
return ActivityKind.TYPE_YOGA;
|
2020-09-07 21:40:20 +02:00
|
|
|
case Cricket:
|
|
|
|
return ActivityKind.TYPE_CRICKET;
|
|
|
|
case Basketball:
|
|
|
|
return ActivityKind.TYPE_BASKETBALL;
|
|
|
|
case PingPong:
|
|
|
|
return ActivityKind.TYPE_PINGPONG;
|
|
|
|
case Badminton:
|
|
|
|
return ActivityKind.TYPE_BADMINTON;
|
2021-01-22 22:14:11 +01:00
|
|
|
case StrengthTraining:
|
|
|
|
return ActivityKind.TYPE_STRENGTH_TRAINING;
|
2017-10-31 23:39:49 +01:00
|
|
|
}
|
|
|
|
throw new RuntimeException("Not mapped activity kind for: " + this);
|
|
|
|
}
|
|
|
|
|
2019-08-13 22:04:52 +02:00
|
|
|
public static HuamiSportsActivityType fromCode(int huamiCode) {
|
|
|
|
for (HuamiSportsActivityType type : values()) {
|
|
|
|
if (type.code == huamiCode) {
|
2017-11-01 20:02:30 +01:00
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
2019-08-13 22:04:52 +02:00
|
|
|
throw new RuntimeException("No matching HuamiSportsActivityType for code: " + huamiCode);
|
2017-11-01 20:02:30 +01:00
|
|
|
}
|
|
|
|
|
2019-08-13 22:04:52 +02:00
|
|
|
public static HuamiSportsActivityType fromActivityKind(int activityKind) {
|
2017-11-01 20:02:30 +01:00
|
|
|
switch (activityKind) {
|
2017-10-31 23:39:49 +01:00
|
|
|
case ActivityKind.TYPE_RUNNING:
|
2020-09-07 21:40:20 +02:00
|
|
|
return OutdoorRunning;
|
2017-10-31 23:39:49 +01:00
|
|
|
case ActivityKind.TYPE_TREADMILL:
|
|
|
|
return Treadmill;
|
|
|
|
case ActivityKind.TYPE_CYCLING:
|
|
|
|
return Cycling;
|
|
|
|
case ActivityKind.TYPE_WALKING:
|
|
|
|
return Walking;
|
2019-01-28 00:22:11 +01:00
|
|
|
case ActivityKind.TYPE_EXERCISE:
|
|
|
|
return Exercise;
|
2019-08-13 22:04:52 +02:00
|
|
|
case ActivityKind.TYPE_SWIMMING:
|
|
|
|
return Swimming;
|
2020-08-16 23:45:52 +02:00
|
|
|
case ActivityKind.TYPE_SWIMMING_OPENWATER:
|
|
|
|
return OpenWaterSwimming;
|
|
|
|
case ActivityKind.TYPE_INDOOR_CYCLING:
|
|
|
|
return IndoorCycling;
|
|
|
|
case ActivityKind.TYPE_ELLIPTICAL_TRAINER:
|
|
|
|
return EllipticalTrainer;
|
2020-09-07 21:40:20 +02:00
|
|
|
case ActivityKind.TYPE_SOCCER:
|
|
|
|
return Soccer;
|
2020-08-16 23:45:52 +02:00
|
|
|
case ActivityKind.TYPE_JUMP_ROPING:
|
|
|
|
return JumpRope;
|
2020-09-07 21:40:20 +02:00
|
|
|
case ActivityKind.TYPE_ROWING_MACHINE:
|
|
|
|
return RowingMachine;
|
2020-08-16 23:45:52 +02:00
|
|
|
case ActivityKind.TYPE_YOGA:
|
|
|
|
return Yoga;
|
2020-09-07 21:40:20 +02:00
|
|
|
case ActivityKind.TYPE_CRICKET:
|
|
|
|
return Cricket;
|
|
|
|
case ActivityKind.TYPE_BASKETBALL:
|
|
|
|
return Basketball;
|
|
|
|
case ActivityKind.TYPE_PINGPONG:
|
|
|
|
return PingPong;
|
|
|
|
case ActivityKind.TYPE_BADMINTON:
|
|
|
|
return Badminton;
|
2021-01-22 22:14:11 +01:00
|
|
|
case ActivityKind.TYPE_STRENGTH_TRAINING:
|
|
|
|
return StrengthTraining;
|
2020-09-07 21:40:20 +02:00
|
|
|
|
2017-10-31 23:39:49 +01:00
|
|
|
}
|
2017-11-01 20:02:30 +01:00
|
|
|
throw new RuntimeException("No matching activity activityKind: " + activityKind);
|
2017-10-31 23:39:49 +01:00
|
|
|
}
|
|
|
|
}
|