@Test public void testBuild() throws Exception { LocalDate today = LocalDate.parse("2014-08-01"); LocalDate min = LocalDate.parse("2014-07-29"); LocalDate max = LocalDate.parse("2014-08-02"); Week week = new Week(today, today, min, max); week.build(); List<Day> days = week.getDays(); assertEquals(7, days.size()); LocalDate first = LocalDate.parse("2014-07-28"); for (int i = 0; i < days.size(); i++) { Day day = days.get(i); assertEquals(first.plusDays(i), day.getDate()); if (i == 4) { assertTrue(day.isToday()); } else { assertFalse(day.isToday()); } if (i > 0 && i < 6) { assertTrue(day.isEnabled()); } else { assertFalse(day.isEnabled()); } } }
@Override public void build() { mDays.clear(); LocalDate date = getFrom(); for(; date.compareTo(getTo()) <= 0; date = date.plusDays(1)) { Day day = new Day(date, date.equals(getToday())); day.setEnabled(isDayEnabled(date)); mDays.add(day); } }
Week extends RangeUnit { @Override public void build() { mDays.clear(); LocalDate date = getFrom(); for(; date.compareTo(getTo()) <= 0; date = date.plusDays(1)) { Day day = new Day(date, date.equals(getToday())); day.setEnabled(isDayEnabled(date)); mDays.add(day); } } }
Week extends RangeUnit { @Override public void build() { mDays.clear(); LocalDate date = getFrom(); for(; date.compareTo(getTo()) <= 0; date = date.plusDays(1)) { Day day = new Day(date, date.equals(getToday())); day.setEnabled(isDayEnabled(date)); mDays.add(day); } } Week(@NonNull LocalDate date, @NonNull LocalDate today, @Nullable LocalDate minDate,
                @Nullable LocalDate maxDate); }
Week extends RangeUnit { @Override public void build() { mDays.clear(); LocalDate date = getFrom(); for(; date.compareTo(getTo()) <= 0; date = date.plusDays(1)) { Day day = new Day(date, date.equals(getToday())); day.setEnabled(isDayEnabled(date)); mDays.add(day); } } Week(@NonNull LocalDate date, @NonNull LocalDate today, @Nullable LocalDate minDate,
                @Nullable LocalDate maxDate); @Override boolean hasNext(); @Override boolean hasPrev(); @Override boolean next(); @Override boolean prev(); @Override int getType(); @Override void deselect(@NonNull LocalDate date); @Override boolean select(@NonNull LocalDate date); @NonNull List<Day> getDays(); @Override void build(); }
Week extends RangeUnit { @Override public void build() { mDays.clear(); LocalDate date = getFrom(); for(; date.compareTo(getTo()) <= 0; date = date.plusDays(1)) { Day day = new Day(date, date.equals(getToday())); day.setEnabled(isDayEnabled(date)); mDays.add(day); } } Week(@NonNull LocalDate date, @NonNull LocalDate today, @Nullable LocalDate minDate,
                @Nullable LocalDate maxDate); @Override boolean hasNext(); @Override boolean hasPrev(); @Override boolean next(); @Override boolean prev(); @Override int getType(); @Override void deselect(@NonNull LocalDate date); @Override boolean select(@NonNull LocalDate date); @NonNull List<Day> getDays(); @Override void build();  }