当前位置: 首页>>代码示例>>Java>>正文


Java DataSet类代码示例

本文整理汇总了Java中com.google.android.gms.fitness.data.DataSet的典型用法代码示例。如果您正苦于以下问题:Java DataSet类的具体用法?Java DataSet怎么用?Java DataSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataSet类属于com.google.android.gms.fitness.data包,在下文中一共展示了DataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
private void processDataSet(DataSet dataSet, WritableArray map) {
    //Log.i(TAG, "Data returned for Data type: " + dataSet.getDataType().getName());

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    dateFormat.setTimeZone(TimeZone.getDefault());

    WritableMap stepMap = Arguments.createMap();

    for (DataPoint dp : dataSet.getDataPoints()) {
        Log.i(TAG, "\tData point:");
        Log.i(TAG, "\t\tType : " + dp.getDataType().getName());
        Log.i(TAG, "\t\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
        Log.i(TAG, "\t\tEnd  : " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));

        for(Field field : dp.getDataType().getFields()) {
            Log.i(TAG, "\t\tField: " + field.getName() +
                    " Value: " + dp.getValue(field));

            stepMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
            stepMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
            stepMap.putDouble("steps", dp.getValue(field).asInt());
            map.pushMap(stepMap);
        }
    }
}
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:26,代码来源:StepHistory.java

示例2: doInBackground

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
protected Void doInBackground(Void... params) {
    // Create a new dataset and insertion request.
    DataSet dataSet = this.WeightsDataset;

    // [START insert_dataset]
    // Then, invoke the History API to insert the data and await the result, which is
    // possible here because of the {@link AsyncTask}. Always include a timeout when calling
    // await() to prevent hanging that can occur from the service being shutdown because
    // of low memory or other conditions.
    //Log.i(TAG, "Inserting the dataset in the History API.");
    com.google.android.gms.common.api.Status insertStatus =
            Fitness.HistoryApi.insertData(googleFitManager.getGoogleApiClient(), dataSet)
                    .await(1, TimeUnit.MINUTES);

    // Before querying the data, check to see if the insertion succeeded.
    if (!insertStatus.isSuccess()) {
        //Log.i(TAG, "There was a problem inserting the dataset.");
        return null;
    }

    //Log.i(TAG, "Data insert was successful!");

    return null;
}
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:25,代码来源:WeightsHistory.java

示例3: createDataForRequest

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
/**
 * This method creates a dataset object to be able to insert data in google fit
 * @param dataType DataType Fitness Data Type object
 * @param dataSourceType int Data Source Id. For example, DataSource.TYPE_RAW
 * @param value Object Values for the fitness data. They must be int or float
 * @param startTime long Time when the fitness activity started
 * @param endTime long Time when the fitness activity finished
 * @param timeUnit TimeUnit Time unit in which period is expressed
 * @return
 */
private DataSet createDataForRequest(DataType dataType, int dataSourceType, Double value,
                                     long startTime, long endTime, TimeUnit timeUnit) {
    DataSource dataSource = new DataSource.Builder()
            .setAppPackageName(GoogleFitPackage.PACKAGE_NAME)
            .setDataType(dataType)
            .setType(dataSourceType)
            .build();

    DataSet dataSet = DataSet.create(dataSource);
    DataPoint dataPoint = dataSet.createDataPoint().setTimeInterval(startTime, endTime, timeUnit);

    float f1 = Float.valueOf(value.toString());
    dataPoint = dataPoint.setFloatValues(f1);

    dataSet.add(dataPoint);

    return dataSet;
}
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:29,代码来源:WeightsHistory.java

示例4: processDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
private void processDataSet(DataSet dataSet, WritableArray map) {
    //Log.i(TAG, "Data returned for Data type: " + dataSet.getDataType().getName());
    Format formatter = new SimpleDateFormat("EEE");

    WritableMap stepMap = Arguments.createMap();


    for (DataPoint dp : dataSet.getDataPoints()) {
        String day = formatter.format(new Date(dp.getStartTime(TimeUnit.MILLISECONDS)));

        int i = 0;

        for (Field field : dp.getDataType().getFields()) {
            i++;
            if (i > 1) continue; //Get only average instance

            stepMap.putString("day", day);
            stepMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
            stepMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
            stepMap.putDouble("value", dp.getValue(field).asFloat());
        }
    }
    map.pushMap(stepMap);
}
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:25,代码来源:WeightsHistory.java

示例5: readBucketValues

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
public void readBucketValues(DataReadResult dataReadResult) {

        bucketSize = 0;
        for (Bucket bucket : dataReadResult.getBuckets()) {

            List<DataSet> dataSets = bucket.getDataSets();

            for (DataSet dataSet : dataSets) {

                if(dataSet.getDataPoints().size()>0)
                {
                    bucketSize++;
                    readDataSetValues(dataSet, true);
                }
            }
        }
        updateUIThread(true);
    }
 
开发者ID:PacktPublishing,项目名称:Android-Sensor-Programming-By-Example,代码行数:19,代码来源:HistoryActivity.java

示例6: showDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
private void showDataSet(DataSet dataSet) {
    sendmessage("Data returned for Data type: " + dataSet.getDataType().getName());
    DateFormat dateFormat = DateFormat.getDateInstance();
    DateFormat timeFormat = getTimeInstance();

    for (DataPoint dp : dataSet.getDataPoints()) {
        //I'm using a handler here to cheat, since I'm not in the asynctask and can't call publishprogress.
        sendmessage("Data point:");
        sendmessage("\tType: " + dp.getDataType().getName());
        sendmessage("\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
        sendmessage("\tEnd: " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
        for (Field field : dp.getDataType().getFields()) {
            sendmessage("\tField: " + field.getName() +
                " Value: " + dp.getValue(field));
        }
    }
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:18,代码来源:SessionFragment.java

示例7: displayTodayData

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
private Task<DataSet> displayTodayData() {
    Log.i(TAG, "Reading History API results for today of Steps");
    return Fitness.getHistoryClient(getActivity(), GoogleSignIn.getLastSignedInAccount(getContext()))
        .readDailyTotal(DataType.TYPE_STEP_COUNT_DELTA)
        .addOnSuccessListener(new OnSuccessListener<DataSet>() {
            @Override
            public void onSuccess(DataSet dataSet) {
                Log.i(TAG, "Reading History API results for today");
                showDataSet(dataSet);
            }
        })
        .addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.i(TAG, "Failed to read DailyTotal for Steps.");
            }
        });

}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:20,代码来源:HistoryFragment.java

示例8: showDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
private void showDataSet(DataSet dataSet) {
    sendmessage("Data returned for Data type: " + dataSet.getDataType().getName());
    DateFormat dateFormat = DateFormat.getDateInstance();
    DateFormat timeFormat = DateFormat.getTimeInstance();

    for (DataPoint dp : dataSet.getDataPoints()) {
        //I'm using a handler here to cheat, since I'm not in the asynctask and can't call publishprogress.
        sendmessage("Data point:");
        sendmessage("\tType: " + dp.getDataType().getName());
        sendmessage("\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
        sendmessage("\tEnd: " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
        for (Field field : dp.getDataType().getFields()) {
            sendmessage("\tField: " + field.getName() +
                " Value: " + dp.getValue(field));
        }
    }
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:18,代码来源:HistoryFragment.java

示例9: locationsFromDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
private List<Location> locationsFromDataSet(DataSet distanceDataSet) {
	List<Location> locations = new ArrayList<>();
	for (DataPoint dataPoint : distanceDataSet.getDataPoints()) {
		float lat = dataPoint.getValue(Field.FIELD_LATITUDE).asFloat();
		float lng = dataPoint.getValue(Field.FIELD_LONGITUDE).asFloat();
		long timestamp = dataPoint.getTimestamp(TimeUnit.MILLISECONDS);
		float accuracy = dataPoint.getValue(Field.FIELD_ACCURACY).asFloat();
		float altitude = dataPoint.getValue(Field.FIELD_ALTITUDE).asFloat();

		Location location = new Location("");
		location.setLatitude(lat);
		location.setLongitude(lng);
		location.setTime(timestamp);
		location.setAccuracy(accuracy);
		location.setAltitude(altitude);
		locations.add(location);
	}
	return locations;
}
 
开发者ID:FauDroids,项目名称:KeepOn,代码行数:20,代码来源:SessionManager.java

示例10: parseDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
/**
 * Walk through all fields in a step_count dataset and return the sum of steps. Used to
 * calculate step counts.
 *
 * @param dataSet set of data from the Google Fit API
 */
private int parseDataSet(DataSet dataSet) {
    int dataSteps = 0;
    for (DataPoint dp : dataSet.getDataPoints()) {
        // Accumulate step count for estimate

        if(dp.getDataType().getName().equals("com.google.step_count.delta")) {

            for (Field field : dp.getDataType().getFields()) {
                if (dp.getValue(field).asInt() > 0) {
                    dataSteps += dp.getValue(field).asInt();
                }
            }
        }
    }
    return dataSteps;
}
 
开发者ID:blackcj,项目名称:GoogleFitExample,代码行数:23,代码来源:DataManager.java

示例11: createStepDeltaDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
/**
 * DataSets can only include one data type.
 *
 * @param startTime Start time for the activity in milliseconds
 * @param endTime End time for the activity in milliseconds
 * @param stepCountDelta Number of steps during the activity
 * @param packageName Package name for the app
 * @return Resulting DataSet
 */
public static DataSet createStepDeltaDataSet(long startTime, long endTime, int stepCountDelta, String packageName, Device device) {

    // Create a data source
    DataSource dataSource = new DataSource.Builder()
            .setAppPackageName(packageName)
            .setDevice(device)
            .setDataType(DataType.TYPE_STEP_COUNT_DELTA)
            .setName(TAG + " - step count")
            .setType(DataSource.TYPE_RAW)
            .build();

    // Create a data set
    DataSet dataSet = DataSet.create(dataSource);
    // For each data point, specify a start time, end time, and the data value -- in this case,
    // the number of new steps.
    DataPoint dataPoint = dataSet.createDataPoint()
            .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS);
    dataPoint.getValue(Field.FIELD_STEPS).setInt(stepCountDelta); // Can't do this on an Activity Segment
    dataSet.add(dataPoint);

    return dataSet;
}
 
开发者ID:blackcj,项目名称:GoogleFitExample,代码行数:32,代码来源:DataQueries.java

示例12: createActivityDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
public static DataSet createActivityDataSet(long startTime, long endTime, String activityName, String packageName, Device device) {

        // Create a data source
        DataSource dataSource = new DataSource.Builder()
                .setAppPackageName(packageName)
                .setDevice(device)
                .setDataType(DataType.TYPE_ACTIVITY_SEGMENT)
                .setName(TAG + " - activity")
                .setType(DataSource.TYPE_RAW)
                .build();

        // Create a data set
        DataSet dataSet = DataSet.create(dataSource);
        // For each data point, specify a start time, end time, and the data value -- in this case,
        // the number of new steps.
        DataPoint activityDataPoint = dataSet.createDataPoint()
                .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS);
        //dataPoint.getValue(Field.FIELD_STEPS).setInt(stepCountDelta); // Can't do this on an Activity Segment
        activityDataPoint.getValue(Field.FIELD_ACTIVITY).setActivity(activityName);
        dataSet.add(activityDataPoint);

        return dataSet;
    }
 
开发者ID:blackcj,项目名称:GoogleFitExample,代码行数:24,代码来源:DataQueries.java

示例13: logDataSet

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
public void logDataSet(List<DataSet> list) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");

    if(list != null) {
        for(DataSet dataSet : list) {
            Log.i(sClassName, "Data returned for Data type: " + dataSet.getDataType().getName());

            for (DataPoint dp : dataSet.getDataPoints()) {
                Log.i(sClassName, "Data point:");
                Log.i(sClassName, "\tType: " + dp.getDataType().getName());
                Log.i(sClassName, "\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
                Log.i(sClassName, "\tEnd: " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
                for(Field field : dp.getDataType().getFields()) {
                    Log.i(sClassName, "\tField: " + field.getName() + " Value: " + dp.getValue(field));
                }
            }
        }
    }
}
 
开发者ID:mklschreiber,项目名称:Crowdi,代码行数:20,代码来源:GooglePortal.java

示例14: testSaveActiveSessionCallBackWithNoRecognisedActivityCreates1DataPoints

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
@SmallTest
public void testSaveActiveSessionCallBackWithNoRecognisedActivityCreates1DataPoints() {

    // setup the mock to return the same start time as set
    startSession(1000);

    when(_mockSession.getStartTime(TimeUnit.MILLISECONDS)).thenReturn((long)1000);

    _sessionManager.saveActiveSession(2000);
    DataSet dataSet = getDataSet();

    assertEquals(1,dataSet.getDataPoints().size());
    assertEquals("Start time should equal session start time",1000,dataSet.getDataPoints().get(0).getStartTime(TimeUnit.MILLISECONDS));
    assertEquals("End time should equal session end time", 2000,dataSet.getDataPoints().get(0).getEndTime(TimeUnit.MILLISECONDS));
    assertEquals("Activity should equal unknown", FitnessActivities.UNKNOWN, dataSet.getDataPoints().get(0).getValue(Field.FIELD_ACTIVITY).asActivity());
}
 
开发者ID:team-mount-ventoux,项目名称:JayPS-AndroidApp,代码行数:17,代码来源:GoogleFitSessionManagerTest.java

示例15: test2DuplicateActivityEventsCreates1DataPoints

import com.google.android.gms.fitness.data.DataSet; //导入依赖的package包/类
@SmallTest
public void test2DuplicateActivityEventsCreates1DataPoints() {
    startSession(1000);

    _sessionManager.addDataPoint(2000, DetectedActivity.RUNNING);
    _sessionManager.addDataPoint(3000, DetectedActivity.RUNNING);

    _sessionManager.saveActiveSession(4000);

    DataSet dataSet = getDataSet();

    assertEquals(1,dataSet.getDataPoints().size());
    assertEquals("Start time should equal data start time",2000,dataSet.getDataPoints().get(0).getStartTime(TimeUnit.MILLISECONDS));
    assertEquals("End time should equal session end time", 4000,dataSet.getDataPoints().get(0).getEndTime(TimeUnit.MILLISECONDS));
    assertEquals("Activity should equal unknown", FitnessActivities.RUNNING, dataSet.getDataPoints().get(0).getValue(Field.FIELD_ACTIVITY).asActivity());
}
 
开发者ID:team-mount-ventoux,项目名称:JayPS-AndroidApp,代码行数:17,代码来源:GoogleFitSessionManagerTest.java


注:本文中的com.google.android.gms.fitness.data.DataSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。