Fixed timestamp conversion for DB, added local variables to make the code clearer

This commit is contained in:
Daniele Gobbetti 2015-06-01 14:17:35 +02:00 committed by cpfeiffer
parent ea97a902d1
commit 9e2d32c33f
1 changed files with 13 additions and 7 deletions

View File

@ -498,19 +498,25 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
private void flushActivityDataHolder() { private void flushActivityDataHolder() {
GregorianCalendar timestamp = this.activityDataTimestampProgress; GregorianCalendar timestamp = this.activityDataTimestampProgress;
byte category, intensity, steps;
for (int i=0; i<this.activityDataHolder.length; i+=3) { for (int i=0; i<this.activityDataHolder.length; i+=3) {
category = this.activityDataHolder[i];
intensity = this.activityDataHolder[i+1];
steps = this.activityDataHolder[i+2];
GBApplication.getActivityDatabaseHandler().addGBActivitySample( GBApplication.getActivityDatabaseHandler().addGBActivitySample(
(int) timestamp.getTimeInMillis() / 1000, (int) (timestamp.getTimeInMillis() / 1000),
GBActivitySample.PROVIDER_MIBAND, GBActivitySample.PROVIDER_MIBAND,
this.activityDataHolder[i+1], intensity,
this.activityDataHolder[i+2], steps,
this.activityDataHolder[i]); category);
ACTIVITYLOG.info( ACTIVITYLOG.info(
" timestamp:"+DateFormat.getDateTimeInstance().format(timestamp.getTime()).toString() + " timestamp:"+DateFormat.getDateTimeInstance().format(timestamp.getTime()).toString() +
" category:"+ this.activityDataHolder[i]+ " category:"+ category+
" intensity:"+this.activityDataHolder[i+1]+ " intensity:"+intensity+
" steps:"+this.activityDataHolder[i+2] " steps:"+steps
); );
timestamp.add(Calendar.MINUTE, 1); timestamp.add(Calendar.MINUTE, 1);
} }