Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/SampleProvider.java

87 lines
2.9 KiB
Java
Raw Normal View History

package nodomain.freeyourgadget.gadgetbridge.devices;
2016-08-27 16:44:47 +02:00
import android.support.annotation.NonNull;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample;
2016-08-27 16:44:47 +02:00
/**
* Interface to retrieve samples from the database, and also create and add samples to the database.
* There are multiple device specific implementations, this interface defines the generic access.
* @param <T> the device/provider specific sample type (must extend AbstractActivitySample)
*/
public interface SampleProvider<T extends AbstractActivitySample> {
// TODO: these constants can all be removed
int PROVIDER_MIBAND = 0;
int PROVIDER_PEBBLE_MORPHEUZ = 1;
int PROVIDER_PEBBLE_GADGETBRIDGE = 2; // removed
int PROVIDER_PEBBLE_MISFIT = 3;
int PROVIDER_PEBBLE_HEALTH = 4;
int PROVIDER_UNKNOWN = 100;
// TODO: can also be removed
2016-08-27 16:44:47 +02:00
/**
* Returns the "id" of this sample provider, as used in Gadgetbridge versions < 0.12.0.
* Only used for importing old samples.
* @deprecated
*/
int getID();
int normalizeType(int rawType);
int toRawActivityKind(int activityKind);
float normalizeIntensity(int rawIntensity);
2016-08-27 16:44:47 +02:00
/**
* Returns the list of all samples, of any type, within the given time span.
* @param timestamp_from the start timestamp
* @param timestamp_to the end timestamp
* @return the list of samples of any type
*/
@NonNull
List<T> getAllActivitySamples(int timestamp_from, int timestamp_to);
2016-08-27 16:44:47 +02:00
/**
* Returns the list of all samples that represent user "activity", within
* the given time span. This excludes samples of type sleep, for example.
* @param timestamp_from the start timestamp
* @param timestamp_to the end timestamp
* @return the list of samples of type user activity, e.g. non-sleep
*/
@NonNull
List<T> getActivitySamples(int timestamp_from, int timestamp_to);
2016-08-27 16:44:47 +02:00
/**
* Returns the list of all samples that represent "sleeping", within the
* given time span.
* @param timestamp_from the start timestamp
* @param timestamp_to the end timestamp
* @return the list of samples of type sleep
*/
@NonNull
List<T> getSleepSamples(int timestamp_from, int timestamp_to);
2016-08-27 16:44:47 +02:00
/**
* Adds the given sample to the database. An existing sample with the same
* timestamp will be overwritten.
* @param activitySample the sample to add
*/
void addGBActivitySample(T activitySample);
2016-08-27 16:44:47 +02:00
/**
* Adds the given samples to the database. Existing samples with the same
* timestamp will be overwritten.
* @param activitySamples the samples to add
*/
void addGBActivitySamples(T[] activitySamples);
2016-06-16 21:54:53 +02:00
2016-08-27 16:44:47 +02:00
/**
* Factory method to creates an empty sample of the correct type for this sample provider
* @return the newly created "empty" sample
*/
2016-06-16 21:54:53 +02:00
T createActivitySample();
}