calendarRangeCallback
The user is allowed to navigate through all eternity.
So if there are many possible meaningful dates, all have to be fetched and populated in the calendars, disabledCalenders and highlightedCalendars lists.
This could become quite a performance and memory issue.
In order to deal with this situation, the calendarRangeCallback property can be used.
The calendarRangeCallback is called each time a different range is shown in the picker and the CalendarRange parameter has the begin and end of the range that is going to be shown.
By registering to the calendarRangeCallback, it is possible to populate the lists with the values relevant to the range.
Example
calendarPicker.setCalendarRangeCallback( (range) -> {
calendarPicker.disabledCalenders().clear;
calendarPicker.disabledCalenders.addAll( BusinessModel.findDisabledCalendarsIn(range.getStartCalendar(), range.getEndCalendar() );
});
valueValidationCallback
Using the disabledCalendars collection only makes sense in non-time mode.
When time is shown, a lot of possibles times (up to milliseconds) can be selected on a single date, so populating the disabledCalendars list with all possible values is practically impossible.
To still be able to prevent certain Calendars to be selected, the valueValidationCallback is an alternative.
It allows, prior to a Calendar being selected, to check if it is allowed.
Example
calendarPicker.valueValidationCallback( (calendar) -> {
if (some_condition(calendar)) {
return false;
}
return true;
});
Important note:
The calendar is treated (and should have been implemented in Java) as immutable.
That means the properties of Calendar are not used to modify its value or listen for changes.
CalendarPicker will create a new instance (clone) each time a new value is put in the calendar property.