private AggregatedRecordedHoursOfDay getAggregatedHoursOfDay(Calendar day) { // TODO SB // get all recorded hour records of that day // aggregate them // add result to map // return result String dbDayString = DateUtil.convertCalendarToDBString(day); Uri uri = Uri.withAppendedPath( AcceleratedAccountingProvider.CONTENT_URI, AcceleratedAccountingProvider.RECORDED_HOURS_CONTENT_DIRECTORY); String where = AcceleratedAccountingProvider.COLUMN_RECORDED_HOURS_DATE + " == ?"; String[] whereArgs = new String[] {dbDayString}; String orderBy = AcceleratedAccountingProvider.COLUMN_RECORDED_HOURS_TIME; List<RecordedHour> recHours = getList(context, uri, null, where, whereArgs, orderBy); // do aggregate List<AggregatedRecordedHour> aggHours = doAggregate(recHours); AggregatedRecordedHoursOfDay aggHoursOfDay = new AggregatedRecordedHoursOfDay(); aggHoursOfDay.setAggRecoredHours(aggHours); aggHoursOfDay.setDayString(DateUtil.convertDateToGermanDateString(day.getTime())); return aggHoursOfDay; }
private String getRoundedTimeString(Calendar time) { // quadrant bestimmen // aggregated recorded hour aus erstem und letztem element des intervalles bilden mit gerundeten // zeiten // TODO: SB this is only the simple version... int hours = time.get(Calendar.HOUR_OF_DAY); int minutes = time.get(Calendar.MINUTE); if (minutes <= 7) { minutes = 0; } else if (minutes > 7 && minutes <= 22) { minutes = 15; } else if (minutes > 22 && minutes <= 37) { minutes = 30; } else if (minutes > 37 && minutes <= 52) { minutes = 45; } else { hours++; minutes = 0; } time.set(Calendar.HOUR, hours); time.set(Calendar.MINUTE, minutes); return DateUtil.convertCalendarToGermanTime(time); }