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


Java DataSet.getDataPoints方法代码示例

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


在下文中一共展示了DataSet.getDataPoints方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: getBasalAVG

import com.google.android.gms.fitness.data.DataSet; //导入方法依赖的package包/类
private float getBasalAVG(long _et) throws Exception {
    float basalAVG = 0;
    Calendar cal = java.util.Calendar.getInstance();
    cal.setTime(new Date(_et));
    //set start time to a week before end time
    cal.add(Calendar.WEEK_OF_YEAR, -1);
    long nst = cal.getTimeInMillis();
    
    DataReadRequest.Builder builder = new DataReadRequest.Builder();
    builder.aggregate(DataType.TYPE_BASAL_METABOLIC_RATE, DataType.AGGREGATE_BASAL_METABOLIC_RATE_SUMMARY);
    builder.bucketByTime(1, TimeUnit.DAYS);
    builder.setTimeRange(nst, _et, TimeUnit.MILLISECONDS);
    DataReadRequest readRequest = builder.build();
    
    DataReadResult dataReadResult = Fitness.HistoryApi.readData(googleFitManager.getGoogleApiClient(), readRequest).await();
    
    if (dataReadResult.getStatus().isSuccess()) {
        JSONObject obj = new JSONObject();
        int avgsN = 0;
        for (Bucket bucket : dataReadResult.getBuckets()) {
            // in the com.google.bmr.summary data type, each data point represents
            // the average, maximum and minimum basal metabolic rate, in kcal per day, over the time interval of the data point.
            DataSet ds = bucket.getDataSet(DataType.AGGREGATE_BASAL_METABOLIC_RATE_SUMMARY);
            for (DataPoint dp : ds.getDataPoints()) {
                float avg = dp.getValue(Field.FIELD_AVERAGE).asFloat();
                basalAVG += avg;
                avgsN++;
            }
        }
        // do the average of the averages
        if (avgsN != 0) basalAVG /= avgsN; // this a daily average
        return basalAVG;
    } else throw new Exception(dataReadResult.getStatus().getStatusMessage());
}
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:35,代码来源:CalorieHistory.java

示例9: 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 = DateFormat.getDateInstance();
    DateFormat timeFormat = DateFormat.getTimeInstance();
    Format formatter = new SimpleDateFormat("EEE");
    WritableMap stepMap = Arguments.createMap();
    
    
    for (DataPoint dp : dataSet.getDataPoints()) {
        Log.i(TAG, "Data point:");
        Log.i(TAG, "\tType: " + dp.getDataType().getName());
        Log.i(TAG, "\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
        Log.i(TAG, "\tEnd: " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)) + " " + timeFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
        
        String day = formatter.format(new Date(dp.getStartTime(TimeUnit.MILLISECONDS)));
        Log.i(TAG, "Day: " + day);
        
        for(Field field : dp.getDataType().getFields()) {
            Log.i("History", "\tField: " + field.getName() +
                  " Value: " + dp.getValue(field));
            
            stepMap.putString("day", day);
            stepMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
            stepMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
            float basal = 0;
            try {
                basal = getBasalAVG(dp.getEndTime(TimeUnit.MILLISECONDS));
            } catch (Exception e) {
                e.printStackTrace();
            }
            stepMap.putDouble("calorie", dp.getValue(field).asFloat() - basal);
            map.pushMap(stepMap);
        }
    }
}
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:36,代码来源:CalorieHistory.java

示例10: 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 = DateFormat.getDateInstance();
    DateFormat timeFormat = DateFormat.getTimeInstance();
    Format formatter = new SimpleDateFormat("EEE");

    WritableMap stepMap = Arguments.createMap();


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

        String day = formatter.format(new Date(dp.getStartTime(TimeUnit.MILLISECONDS)));
        Log.i(TAG, "Day: " + day);

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

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

示例11: dumpDataSet

import com.google.android.gms.fitness.data.DataSet; //导入方法依赖的package包/类
private static void dumpDataSet(DataSet dataSet) {
    Log.i(TAG, "Data returned for Data type: " + dataSet.getDataType().getName());
    DateFormat dateFormat = getTimeInstance();

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

示例12: convertDatasetToJson

import com.google.android.gms.fitness.data.DataSet; //导入方法依赖的package包/类
/**
 * Convert a DataSet into its JSON representation
 * @param dataSet
 * @return
 */
private JSONArray convertDatasetToJson(DataSet dataSet) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);

    JSONArray dataSet_JSON = new JSONArray();

    for (DataPoint dp : dataSet.getDataPoints()) {
        JSONObject dataPoint_JSON = new JSONObject();

        try {
            dataPoint_JSON.put("type", dp.getDataType().getName());
            DataSource dataSource = dp.getOriginalDataSource();
            String appPkgName = dataSource.getAppPackageName();
            dataPoint_JSON.put("source", appPkgName);
            dataPoint_JSON.put("start", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
            dataPoint_JSON.put("end", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));

            JSONArray field_value_pairs = new JSONArray();

            for(Field field : dp.getDataType().getFields()) {
                JSONObject field_value_pair = new JSONObject();
                field_value_pair.put("field", field.getName());
                field_value_pair.put("value", dp.getValue(field));
                field_value_pairs.put(field_value_pair);
            }
            dataPoint_JSON.put("fields", field_value_pairs);

            dataSet_JSON.put(dataPoint_JSON);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    return dataSet_JSON;
}
 
开发者ID:2dvisio,项目名称:cordova-plugin-googlefit,代码行数:40,代码来源:GoogleFit.java

示例13: onResult

import com.google.android.gms.fitness.data.DataSet; //导入方法依赖的package包/类
@Override
public void onResult(DataReadResult activitiesResponse) {
	FitnessActivityDistances activityDistances = new FitnessActivityDistances();

	for (Bucket activityBucket : activitiesResponse.getBuckets()) {
		String activity = activityBucket.getActivity();

		for (DataSet activityDataSet : activityBucket.getDataSets()) {

			for (DataPoint activityDataPoint : activityDataSet.getDataPoints()) {
				float activityDistance = activityDataPoint.getValue(Field.FIELD_DISTANCE).asFloat();

				if (walkingActivities.contains(activity)) {
					activityDistances.getWalkingDistance().plus(activityDistance);
					continue;
				}

				if (runningActivities.contains(activity)) {
					activityDistances.getRunningDistance().plus(activityDistance);
					continue;
				}

				if (bikingActivities.contains(activity)) {
					activityDistances.getBikingDistance().plus(activityDistance);
					continue;
				}
			}
		}
	}

	BusProvider.getBus().post(new FitnessActivityDistancesLoadedEvent(activityDistances));
}
 
开发者ID:ming13,项目名称:to-the-moon,代码行数:33,代码来源:FitnessActivityDistancesStorage.java

示例14: convertToStepBucketList

import com.google.android.gms.fitness.data.DataSet; //导入方法依赖的package包/类
public List<StepBucket> convertToStepBucketList(List<Bucket> list) {
    List<StepBucket> returnList = new ArrayList<>();

    try {
        if(list != null) {
            for(Bucket bucket : list) {
                List<DataSet> dataSets = bucket.getDataSets();

                if(dataSets != null) {
                    for(DataSet dataSet : dataSets) {
                        for(DataPoint dp : dataSet.getDataPoints()) {
                            StepBucket stepBucket = new StepBucket();

                            Field field = getField(dp.getDataType().getFields(), "steps");

                            if(field != null) {
                                stepBucket.setStepCount(dp.getValue(field).asInt());
                            }

                            Calendar c = Calendar.getInstance();

                            c.setTimeInMillis(dp.getStartTime(TimeUnit.MILLISECONDS));
                            stepBucket.setStepStartDate(c.getTime());

                            c.setTimeInMillis(dp.getEndTime(TimeUnit.MILLISECONDS));
                            stepBucket.setStepEndDate(c.getTime());

                            returnList.add(stepBucket);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        // Something went wrong
    }

    return returnList;
}
 
开发者ID:mklschreiber,项目名称:Crowdi,代码行数:40,代码来源:GooglePortal.java

示例15: parseDataSet

import com.google.android.gms.fitness.data.DataSet; //导入方法依赖的package包/类
public void parseDataSet(DataSet dataSet) {
    for(DataPoint dp : dataSet.getDataPoints()) {
        Date start = new Date(dp.getStartTime(TimeUnit.MILLISECONDS));
        Date end = new Date(dp.getEndTime(TimeUnit.MILLISECONDS));
        Log.d(LOG_TAG, "Type: " + dp.getDataType().getName());
        Log.d(LOG_TAG, "Date: " + start + ":" + end);
        for(Field field : dp.getDataType().getFields()) {
            Log.d(LOG_TAG, "Field: " + field.getName() + " Value: " + dp.getValue(field));
        }
    }
}
 
开发者ID:jareddlc,项目名称:OpenFit,代码行数:12,代码来源:GoogleFit.java


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