2015-08-03 23:09:49 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.model;
|
2015-07-14 00:29:32 +02:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
2015-08-03 23:09:49 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
2015-07-14 00:29:32 +02:00
|
|
|
|
|
|
|
public class ActivityKind {
|
2016-07-27 23:34:13 +02:00
|
|
|
public static final int TYPE_NOT_MEASURED = -1;
|
2015-07-27 23:49:53 +02:00
|
|
|
public static final int TYPE_UNKNOWN = 0;
|
2015-07-14 00:29:32 +02:00
|
|
|
public static final int TYPE_ACTIVITY = 1;
|
|
|
|
public static final int TYPE_LIGHT_SLEEP = 2;
|
|
|
|
public static final int TYPE_DEEP_SLEEP = 4;
|
2015-08-28 14:54:49 +02:00
|
|
|
public static final int TYPE_NOT_WORN = 8;
|
2015-08-28 14:35:22 +02:00
|
|
|
|
2015-07-14 00:29:32 +02:00
|
|
|
public static final int TYPE_SLEEP = TYPE_LIGHT_SLEEP | TYPE_DEEP_SLEEP;
|
2015-08-28 14:54:49 +02:00
|
|
|
public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP | TYPE_NOT_WORN;
|
2015-07-14 00:29:32 +02:00
|
|
|
|
2016-02-29 20:54:39 +01:00
|
|
|
public static int[] mapToDBActivityTypes(int types, SampleProvider provider) {
|
|
|
|
int[] result = new int[3];
|
2015-07-14 00:29:32 +02:00
|
|
|
int i = 0;
|
|
|
|
if ((types & ActivityKind.TYPE_ACTIVITY) != 0) {
|
2015-07-27 23:49:53 +02:00
|
|
|
result[i++] = provider.toRawActivityKind(TYPE_ACTIVITY);
|
2015-07-14 00:29:32 +02:00
|
|
|
}
|
|
|
|
if ((types & ActivityKind.TYPE_DEEP_SLEEP) != 0) {
|
2015-07-27 23:49:53 +02:00
|
|
|
result[i++] = provider.toRawActivityKind(TYPE_DEEP_SLEEP);
|
2015-07-14 00:29:32 +02:00
|
|
|
}
|
|
|
|
if ((types & ActivityKind.TYPE_LIGHT_SLEEP) != 0) {
|
2015-07-27 23:49:53 +02:00
|
|
|
result[i++] = provider.toRawActivityKind(TYPE_LIGHT_SLEEP);
|
2015-07-14 00:29:32 +02:00
|
|
|
}
|
2015-08-28 14:54:49 +02:00
|
|
|
if ((types & ActivityKind.TYPE_NOT_WORN) != 0) {
|
|
|
|
result[i++] = provider.toRawActivityKind(TYPE_NOT_WORN);
|
|
|
|
}
|
2015-07-14 00:29:32 +02:00
|
|
|
return Arrays.copyOf(result, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|