//Material Date Picker
private val calendar = Calendar.getInstance()
private val constraintsBuilder = CalendarConstraints.Builder().setStart(calendar.timeInMillis)
priv
You need to create your own DateValidator for this. A date being enabled/disabled depends on whether DateValidator.isValid()
returns true or false
@Parcelize
class FutureDateValidator : CalendarConstraints.DateValidator {
override fun isValid(date: Long): Boolean {
return date > System.currentTimeMillis()
}
}
And then use this validator as:
CalendarConstraints.Builder()
.setValidator(FutureDateValidator())
.build()
You can build your own DateValidator
or you can just use the DateValidatorPointForward
provided by the library.
Something like:
//Returns a DateValidator which enables days from {@code point}, in
//UTC milliseconds, forward
CalendarConstraints.DateValidator dateValidator = DateValidatorPointForward.from(yourDate);
constraintsBuilder.setValidator(dateValidator);