private void dumpDataSet(DataSet dataSet) { DateFormat dateFormat = getTimeInstance(); // Cambiar el formato de fecha? fecha con dias for (DataPoint dp : dataSet.getDataPoints()) { ParseObject testObject = new ParseObject("PasosDia"); testObject.put("Steps", dp.getValue(Field.FIELD_STEPS).toString()); testObject.put("StartDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS))); testObject.put("EndDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS))); testObject.put("Usuario", ParseUser.getCurrentUser()); testObject.saveInBackground(); } }
private Bundle formatStepCount(DataReadResult dataReadResult) { Bundle bundle = new Bundle(); // Step Count List<DataPoint> dataPointList = dataReadResult.getDataSet(DataType.TYPE_STEP_COUNT_DELTA).getDataPoints(); int[] steps = new int[dataPointList.size()]; long[] startTime = new long[dataPointList.size()]; long[] endTime = new long[dataPointList.size()]; int idx = 0; for (DataPoint dp : dataPointList) { steps[idx] = dp.getValue(Field.FIELD_STEPS).asInt(); startTime[idx] = dp.getStartTime(TimeUnit.MILLISECONDS); endTime[idx] = dp.getEndTime(TimeUnit.MILLISECONDS); ++idx; } bundle.putIntArray("STEPS", steps); bundle.putLongArray("START_TIME", startTime); bundle.putLongArray("END_TIME", endTime); Log.d(TAG, String.format("Step data points: %d", idx)); return bundle; }
private Bundle formatDistance(DataReadResult dataReadResult) { Bundle bundle = new Bundle(); // Distance List<DataPoint> dataPointList = dataReadResult.getDataSet(DataType.TYPE_DISTANCE_DELTA).getDataPoints(); float[] distance = new float[dataPointList.size()]; long[] startTime = new long[dataPointList.size()]; long[] endTime = new long[dataPointList.size()]; int idx = 0; for (DataPoint dp : dataPointList) { distance[idx] = dp.getValue(Field.FIELD_DISTANCE).asFloat(); startTime[idx] = dp.getStartTime(TimeUnit.MILLISECONDS); endTime[idx] = dp.getEndTime(TimeUnit.MILLISECONDS); ++idx; } bundle.putFloatArray("DISTANCE", distance); bundle.putLongArray("START_TIME", startTime); bundle.putLongArray("END_TIME", endTime); Log.d(TAG, String.format("Distance data points: %d", idx)); return bundle; }
private Bundle formatCalories(DataReadResult dataReadResult) { Bundle bundle = new Bundle(); // Calorie expenditure List<DataPoint> dataPointList = dataReadResult.getDataSet(DataType.TYPE_CALORIES_EXPENDED).getDataPoints(); float[] calories = new float[dataPointList.size()]; long[] startTime = new long[dataPointList.size()]; long[] endTime = new long[dataPointList.size()]; int idx = 0; for (DataPoint dp : dataPointList) { calories[idx] = dp.getValue(Field.FIELD_CALORIES).asFloat(); startTime[idx] = dp.getStartTime(TimeUnit.MILLISECONDS); endTime[idx] = dp.getEndTime(TimeUnit.MILLISECONDS); ++idx; } bundle.putFloatArray("CALORIES", calories); bundle.putLongArray("START_TIME", startTime); bundle.putLongArray("END_TIME", endTime); Log.d(TAG, String.format("Calorie data points: %d", idx)); return bundle; }