@Test public void hasCorrectDayLabels() { final String[] labels = sensorLabelInteractor.generateDayLabels(getCalendar()); assertEquals(labels.length, 7); assertEquals("1PM", labels[0]); assertEquals("5PM", labels[1]); assertEquals("8PM", labels[2]); assertEquals("12AM", labels[3]); assertEquals("3AM", labels[4]); assertEquals("7AM", labels[5]); assertEquals("10AM", labels[6]); }
@NonNull @VisibleForTesting String[] generateDayLabels(@NonNull final Calendar calendar) { final String[] labels = new String[7]; final SimpleDateFormat dateFormat; final int minuteDiff; if (this.preferencesInteractor.getUse24Time()) { dateFormat = new SimpleDateFormat("HH:mm", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 15; calendar.add(Calendar.MINUTE, unRoundedMins < 8 ? -unRoundedMins : (15 - unRoundedMins)); calendar.add(Calendar.MINUTE, 15); minuteDiff = -25; } else { dateFormat = new SimpleDateFormat("ha", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 30; calendar.add(Calendar.MINUTE, 30 - unRoundedMins); minuteDiff = -30; } calendar.add(Calendar.HOUR, -2); for (int i = 6; i >= 0; i--) { final String day = dateFormat.format(calendar.getTime()); labels[i] = day.toUpperCase(); calendar.add(Calendar.HOUR, -3); calendar.add(Calendar.MINUTE, minuteDiff); } return labels; }
SensorLabelInteractor extends Interactor { @NonNull @VisibleForTesting String[] generateDayLabels(@NonNull final Calendar calendar) { final String[] labels = new String[7]; final SimpleDateFormat dateFormat; final int minuteDiff; if (this.preferencesInteractor.getUse24Time()) { dateFormat = new SimpleDateFormat("HH:mm", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 15; calendar.add(Calendar.MINUTE, unRoundedMins < 8 ? -unRoundedMins : (15 - unRoundedMins)); calendar.add(Calendar.MINUTE, 15); minuteDiff = -25; } else { dateFormat = new SimpleDateFormat("ha", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 30; calendar.add(Calendar.MINUTE, 30 - unRoundedMins); minuteDiff = -30; } calendar.add(Calendar.HOUR, -2); for (int i = 6; i >= 0; i--) { final String day = dateFormat.format(calendar.getTime()); labels[i] = day.toUpperCase(); calendar.add(Calendar.HOUR, -3); calendar.add(Calendar.MINUTE, minuteDiff); } return labels; } }
SensorLabelInteractor extends Interactor { @NonNull @VisibleForTesting String[] generateDayLabels(@NonNull final Calendar calendar) { final String[] labels = new String[7]; final SimpleDateFormat dateFormat; final int minuteDiff; if (this.preferencesInteractor.getUse24Time()) { dateFormat = new SimpleDateFormat("HH:mm", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 15; calendar.add(Calendar.MINUTE, unRoundedMins < 8 ? -unRoundedMins : (15 - unRoundedMins)); calendar.add(Calendar.MINUTE, 15); minuteDiff = -25; } else { dateFormat = new SimpleDateFormat("ha", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 30; calendar.add(Calendar.MINUTE, 30 - unRoundedMins); minuteDiff = -30; } calendar.add(Calendar.HOUR, -2); for (int i = 6; i >= 0; i--) { final String day = dateFormat.format(calendar.getTime()); labels[i] = day.toUpperCase(); calendar.add(Calendar.HOUR, -3); calendar.add(Calendar.MINUTE, minuteDiff); } return labels; }  }
SensorLabelInteractor extends Interactor { @NonNull @VisibleForTesting String[] generateDayLabels(@NonNull final Calendar calendar) { final String[] labels = new String[7]; final SimpleDateFormat dateFormat; final int minuteDiff; if (this.preferencesInteractor.getUse24Time()) { dateFormat = new SimpleDateFormat("HH:mm", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 15; calendar.add(Calendar.MINUTE, unRoundedMins < 8 ? -unRoundedMins : (15 - unRoundedMins)); calendar.add(Calendar.MINUTE, 15); minuteDiff = -25; } else { dateFormat = new SimpleDateFormat("ha", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 30; calendar.add(Calendar.MINUTE, 30 - unRoundedMins); minuteDiff = -30; } calendar.add(Calendar.HOUR, -2); for (int i = 6; i >= 0; i--) { final String day = dateFormat.format(calendar.getTime()); labels[i] = day.toUpperCase(); calendar.add(Calendar.HOUR, -3); calendar.add(Calendar.MINUTE, minuteDiff); } return labels; }  @NonNull String[] getWeekLabels(); @NonNull String[] getDayLabels(); }
SensorLabelInteractor extends Interactor { @NonNull @VisibleForTesting String[] generateDayLabels(@NonNull final Calendar calendar) { final String[] labels = new String[7]; final SimpleDateFormat dateFormat; final int minuteDiff; if (this.preferencesInteractor.getUse24Time()) { dateFormat = new SimpleDateFormat("HH:mm", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 15; calendar.add(Calendar.MINUTE, unRoundedMins < 8 ? -unRoundedMins : (15 - unRoundedMins)); calendar.add(Calendar.MINUTE, 15); minuteDiff = -25; } else { dateFormat = new SimpleDateFormat("ha", Locale.getDefault()); final int unRoundedMins = calendar.get(Calendar.MINUTE) % 30; calendar.add(Calendar.MINUTE, 30 - unRoundedMins); minuteDiff = -30; } calendar.add(Calendar.HOUR, -2); for (int i = 6; i >= 0; i--) { final String day = dateFormat.format(calendar.getTime()); labels[i] = day.toUpperCase(); calendar.add(Calendar.HOUR, -3); calendar.add(Calendar.MINUTE, minuteDiff); } return labels; }  @NonNull String[] getWeekLabels(); @NonNull String[] getDayLabels();  }