Bucket

public class Bucket extends AbstractSafeParcelable
implements Parcelable

A bucket represents a time interval over which aggregated data is computed. For example, a bucket can represent user's average speed and average heart rate over a 1 hour interval. Currently we allow buckets to be computed by only one of the following strategies:

  1. time: a time bucket can represent a full day, hour, or any other desired interval
  2. session: a session bucket represents data for one session
  3. activity type: an activity type represents one of the FitnessActivities
  4. activity segments: an activity segment represents data for one activity segment

A Bucket consists of the following fields:

  • startTime denotes the start time of the bucket. This field is always present.
  • endTime denotes the end time of the bucket. This field is always present.
  • session denotes the associated session with the bucket. This is an optional field that is set only if the read query had requested bucketing by sessions.
  • activity denotes the associated activity with the bucket as defined in FitnessActivities. This is an optional field and is set only if the read query had requested bucketing of data by activity segments.
  • dataSets DataSets for the aggregated data types requested in the read query over the time interval of this bucket.
  • bucketType denotes if the bucketing is by time, session or activity. This field is always present and set to one of TYPE_TIME, TYPE_SESSION, TYPE_ACTIVITY_SEGMENT or TYPE_ACTIVITY_TYPE.

Constant Summary

int TYPE_ACTIVITY_SEGMENT Type constant denoting that bucketing by individual activity segment is requested.
int TYPE_ACTIVITY_TYPE Type constant denoting that bucketing by activity type is requested.
int TYPE_SESSION Type constant denoting that bucketing by session is requested.
int TYPE_TIME Type constant denoting that bucketing by time is requested.

Inherited Constant Summary

Public Method Summary

boolean
equals(Object other)
String
getActivity()
Returns the activity of the bucket if bucketing by activity was requested, or UNKNOWN otherwise.
int
getBucketType()
Returns the type of the bucket.
DataSet
getDataSet(DataType dataType)
Returns the data set of requested data type over the time interval of the bucket.
List<DataSet>
getDataSets()
Returns the requested data sets over the time interval of the bucket.
long
getEndTime(TimeUnit timeUnit)
Returns the end time of the bucket, in the given time unit since epoch.
Session
getSession()
Returns the session of the bucket if bucketing by session was requested, null otherwise.
long
getStartTime(TimeUnit timeUnit)
Returns the start time of the bucket, in the given time unit since epoch.
int
String
void
writeToParcel(Parcel dest, int flags)

Inherited Method Summary

Constants

public static final int TYPE_ACTIVITY_SEGMENT

Type constant denoting that bucketing by individual activity segment is requested.

Constant Value: 4

public static final int TYPE_ACTIVITY_TYPE

Type constant denoting that bucketing by activity type is requested.

Constant Value: 3

public static final int TYPE_SESSION

Type constant denoting that bucketing by session is requested.

Constant Value: 2

public static final int TYPE_TIME

Type constant denoting that bucketing by time is requested.

Constant Value: 1

Public Methods

public boolean equals (Object other)

public String getActivity ()

Returns the activity of the bucket if bucketing by activity was requested, or UNKNOWN otherwise.

public int getBucketType ()

Returns the type of the bucket.

public DataSet getDataSet (DataType dataType)

Returns the data set of requested data type over the time interval of the bucket. Returns null, if data set for the requested type is not found.

public List<DataSet> getDataSets ()

Returns the requested data sets over the time interval of the bucket.

public long getEndTime (TimeUnit timeUnit)

Returns the end time of the bucket, in the given time unit since epoch.

public Session getSession ()

Returns the session of the bucket if bucketing by session was requested, null otherwise.

public long getStartTime (TimeUnit timeUnit)

Returns the start time of the bucket, in the given time unit since epoch.

public int hashCode ()

public String toString ()

public void writeToParcel (Parcel dest, int flags)