CalendarUnit { public boolean isInView(@NonNull LocalDate date) { return !mFrom.withDayOfWeek(DateTimeConstants.MONDAY).isAfter(date) && !mTo.withDayOfWeek(DateTimeConstants.SUNDAY).isBefore(date); } protected  CalendarUnit(@NonNull LocalDate from, @NonNull LocalDate to, @NonNull LocalDate today); LocalDate getToday(); LocalDate getFrom(); LocalDate getTo(); boolean isSelected(); abstract boolean hasNext(); abstract boolean hasPrev(); abstract boolean next(); abstract boolean prev(); @CalendarType abstract int getType(); boolean isIn(@NonNull LocalDate date); boolean isInView(@NonNull LocalDate date); abstract void deselect(@NonNull LocalDate date); abstract boolean select(@NonNull LocalDate date); abstract void build(); @Override boolean equals(Object o); @Override int hashCode(); static final int TYPE_WEEK; static final int TYPE_MONTH; }
@Test public void testIsInView() throws Exception { LocalDate today = LocalDate.now(); assertTrue(mUnit.isInView(today.withDayOfWeek(DateTimeConstants.MONDAY))); assertTrue(mUnit.isInView(today.withDayOfWeek(DateTimeConstants.WEDNESDAY))); assertTrue(mUnit.isInView(today.withDayOfWeek(DateTimeConstants.SUNDAY))); }
@Test public void testIsInViewBefore() throws Exception { LocalDate prevWeek = LocalDate.now().minusWeeks(1); assertFalse(mUnit.isInView(prevWeek.withDayOfWeek(DateTimeConstants.SUNDAY))); }
@Test public void testIsInViewAfter() throws Exception { LocalDate nextWeek = LocalDate.now().plusWeeks(1); assertFalse(mUnit.isInView(nextWeek.withDayOfWeek(DateTimeConstants.MONDAY))); }