/** * Select a new date. Respects the {@link SelectionMode} this CalendarPickerView is configured * with: if you are in {@link SelectionMode#SINGLE}, the previously selected date will be * un-selected. In {@link SelectionMode#MULTIPLE}, the new date will be added to the list of * selected dates. * * <p>If the selection was made (selectable date, in range), the view will scroll to the newly * selected date if it's not already visible. * * @return - whether we were able to set the date */ public boolean selectDate(Date date) { validateDate(date); MonthCellWithMonthIndex monthCellWithMonthIndex = getMonthCellWithIndexByDate(date); if (monthCellWithMonthIndex == null || !isDateSelectable(date)) { return false; } boolean wasSelected = doSelectDate(date, monthCellWithMonthIndex.cell); if (wasSelected) { scrollToSelectedMonth(monthCellWithMonthIndex.monthIndex); } return wasSelected; }
public void highlightDates(Collection<Date> dates) { for (Date date : dates) { validateDate(date); MonthCellWithMonthIndex monthCellWithMonthIndex = getMonthCellWithIndexByDate(date); if (monthCellWithMonthIndex != null) { Calendar newlyHighlightedCal = Calendar.getInstance(); newlyHighlightedCal.setTime(date); MonthCellDescriptor cell = monthCellWithMonthIndex.cell; highlightedCells.add(cell); highlightedCals.add(newlyHighlightedCal); cell.setHighlighted(true); } } adapter.notifyDataSetChanged(); setAdapter(adapter); }