Search in sources :

Example 1 with DataSource

use of com.google.android.gms.fitness.data.DataSource in project Zweet-Fit-App by rachit0904.

the class StatData_TestActivity method getDataRequestForWeeks.

// create request to retrieve step history for specific weeks
public static DataReadRequest getDataRequestForWeeks(int weeks) {
    Calendar cal = Calendar.getInstance();
    Date now = new Date();
    cal.setTime(now);
    long endTime = cal.getTimeInMillis();
    cal.add(Calendar.WEEK_OF_YEAR, -1 * weeks);
    long startTime = cal.getTimeInMillis();
    java.text.DateFormat dateFormat = DateFormat.getDateInstance();
    Log.e(TAG, "Range Start: " + dateFormat.format(startTime));
    Log.e(TAG, "Range End: " + dateFormat.format(endTime));
    final DataSource ds = new DataSource.Builder().setAppPackageName("com.google.android.gms").setDataType(DataType.TYPE_STEP_COUNT_DELTA).setType(DataSource.TYPE_DERIVED).setStreamName("estimated_steps").build();
    DataReadRequest readRequest = new DataReadRequest.Builder().aggregate(ds, DataType.TYPE_STEP_COUNT_DELTA).bucketByTime(1, TimeUnit.DAYS).setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS).build();
    return readRequest;
}
Also used : Calendar(java.util.Calendar) DataReadRequest(com.google.android.gms.fitness.request.DataReadRequest) Date(java.util.Date) DateFormat(java.text.DateFormat) DataSource(com.google.android.gms.fitness.data.DataSource)

Example 2 with DataSource

use of com.google.android.gms.fitness.data.DataSource in project Zweet-Fit-App by rachit0904.

the class home_fragment method getDataRequestForWeeks.

// create request to retrieve step history for specific weeks
public static DataReadRequest getDataRequestForWeeks(String startDate, String endDate) {
    long start = LocalDateTime.of(Integer.parseInt(startDate.split("-")[0]), Integer.parseInt(startDate.split("-")[1]), Integer.parseInt(startDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    long end = LocalDateTime.of(Integer.parseInt(endDate.split("-")[0]), Integer.parseInt(endDate.split("-")[1]), Integer.parseInt(endDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    java.text.DateFormat dateFormat = DateFormat.getDateInstance();
    Log.e(TAG, "Range Start: " + (startDate));
    Log.e(TAG, "Range End: " + (endDate));
    final DataSource ds = new DataSource.Builder().setAppPackageName("com.google.android.gms").setDataType(DataType.TYPE_STEP_COUNT_DELTA).setType(DataSource.TYPE_DERIVED).setStreamName("estimated_steps").build();
    DataReadRequest readRequest = new DataReadRequest.Builder().aggregate(ds, DataType.TYPE_STEP_COUNT_DELTA).bucketByTime(1, TimeUnit.DAYS).setTimeRange(start, end, TimeUnit.SECONDS).build();
    return readRequest;
}
Also used : DataReadRequest(com.google.android.gms.fitness.request.DataReadRequest) Context(android.content.Context) DateFormat(java.text.DateFormat) DataSource(com.google.android.gms.fitness.data.DataSource)

Example 3 with DataSource

use of com.google.android.gms.fitness.data.DataSource in project Zweet-Fit-App by rachit0904.

the class DailyStatView method getDataRequestForWeeks.

// create request to retrieve step history for specific weeks
public static DataReadRequest getDataRequestForWeeks(String startDate, String endDate) {
    long start = LocalDateTime.of(Integer.parseInt(startDate.split("-")[0]), Integer.parseInt(startDate.split("-")[1]), Integer.parseInt(startDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    long end = LocalDateTime.of(Integer.parseInt(endDate.split("-")[0]), Integer.parseInt(endDate.split("-")[1]), Integer.parseInt(endDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    java.text.DateFormat dateFormat = DateFormat.getDateInstance();
    Log.e(TAG, "Range Start: " + (startDate));
    Log.e(TAG, "Range End: " + (endDate));
    final DataSource ds = new DataSource.Builder().setAppPackageName("com.google.android.gms").setDataType(DataType.TYPE_STEP_COUNT_DELTA).setType(DataSource.TYPE_DERIVED).setStreamName("estimated_steps").build();
    DataReadRequest readRequest = new DataReadRequest.Builder().aggregate(ds, DataType.TYPE_STEP_COUNT_DELTA).bucketByTime(1, TimeUnit.DAYS).setTimeRange(start, end, TimeUnit.SECONDS).build();
    return readRequest;
}
Also used : DataReadRequest(com.google.android.gms.fitness.request.DataReadRequest) Context(android.content.Context) DateFormat(java.text.DateFormat) DataSource(com.google.android.gms.fitness.data.DataSource)

Example 4 with DataSource

use of com.google.android.gms.fitness.data.DataSource in project Zweet-Fit-App by rachit0904.

the class WeeklyStatView method getDataRequestForDuration.

// create request to retrieve step history for specific weeks
public static DataReadRequest getDataRequestForDuration(String startDate, String endDate) {
    long start = LocalDateTime.of(Integer.parseInt(startDate.split("-")[0]), Integer.parseInt(startDate.split("-")[1]), Integer.parseInt(startDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    long end = LocalDateTime.of(Integer.parseInt(endDate.split("-")[0]), Integer.parseInt(endDate.split("-")[1]), Integer.parseInt(endDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    java.text.DateFormat dateFormat = DateFormat.getDateInstance();
    Log.e(TAG, "Range Start: " + dateFormat.format(start));
    Log.e(TAG, "Range End: " + dateFormat.format(end));
    final DataSource ds = new DataSource.Builder().setAppPackageName("com.google.android.gms").setDataType(DataType.TYPE_STEP_COUNT_DELTA).setType(DataSource.TYPE_DERIVED).setStreamName("estimated_steps").build();
    DataReadRequest readRequest = new DataReadRequest.Builder().aggregate(ds, DataType.TYPE_STEP_COUNT_DELTA).bucketByTime(1, TimeUnit.DAYS).setTimeRange(start, end, TimeUnit.SECONDS).build();
    return readRequest;
}
Also used : DataReadRequest(com.google.android.gms.fitness.request.DataReadRequest) Context(android.content.Context) DateFormat(java.text.DateFormat) DataSource(com.google.android.gms.fitness.data.DataSource)

Example 5 with DataSource

use of com.google.android.gms.fitness.data.DataSource in project Zweet-Fit-App by rachit0904.

the class YearlyFragment method getDataRequestForWeeks.

// create request to retrieve step history for specific weeks
public static DataReadRequest getDataRequestForWeeks(String startDate, String endDate) {
    long start = LocalDateTime.of(Integer.parseInt(startDate.split("-")[0]), Integer.parseInt(startDate.split("-")[1]), Integer.parseInt(startDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    long end = LocalDateTime.of(Integer.parseInt(endDate.split("-")[0]), Integer.parseInt(endDate.split("-")[1]), Integer.parseInt(endDate.split("-")[2]), 0, 0).toEpochSecond(ZoneOffset.UTC);
    java.text.DateFormat dateFormat = DateFormat.getDateInstance();
    Log.e(TAG, "Range Start: " + (startDate));
    Log.e(TAG, "Range End: " + (endDate));
    final DataSource ds = new DataSource.Builder().setAppPackageName("com.google.android.gms").setDataType(DataType.TYPE_STEP_COUNT_DELTA).setType(DataSource.TYPE_DERIVED).setStreamName("estimated_steps").build();
    DataReadRequest readRequest = new DataReadRequest.Builder().aggregate(ds, DataType.TYPE_STEP_COUNT_DELTA).bucketByTime(1, TimeUnit.DAYS).setTimeRange(start, end, TimeUnit.SECONDS).build();
    return readRequest;
}
Also used : DataReadRequest(com.google.android.gms.fitness.request.DataReadRequest) DateFormat(java.text.DateFormat) DataSource(com.google.android.gms.fitness.data.DataSource)

Aggregations

DataSource (com.google.android.gms.fitness.data.DataSource)6 DataReadRequest (com.google.android.gms.fitness.request.DataReadRequest)6 DateFormat (java.text.DateFormat)6 Context (android.content.Context)4 Calendar (java.util.Calendar)1 Date (java.util.Date)1