I have a requirement where I have a list of entities, and every entity has their own set of disabledDays
So whenever I select an entity, I have to set it's disabledDays to the DatePickerDialog.
I was trying to maintain a single instance of DatePickerDialog so I don't have to re-create it every time I have to show it. I was hoping that if I just call the setDisabledDays(...) method and set the disabled dates, the new dates passed would overwrite the previous values and be disabled.
So when calling datePickerDialog.setDisabledDays(disabledDays.distinct()), it is working as expected for the first selection, but for the next selection, when it is called again on the same DatePickerDialog instance, the new dates are added to the mDefaultLimiter.disabledDays set.
Currently the only way to avoid this issue is to create a new DatePickerDialog instance everytime we need it, but an other alternative (using the same instance) can be:
Inside the DefaultDateRangeLimiter class, we have:
I think a method like addDisabledDates(...) can be more right for the users to know that the dates are being added, not replaced, So we can move the logic of setDisabledDates() method to addDisabledDates(), call the latter from the former, and deprecate the former method.
I have a requirement where I have a list of entities, and every entity has their own set of
disabledDays
So whenever I select an entity, I have to set it's disabledDays to theDatePickerDialog
.I was trying to maintain a single instance of DatePickerDialog so I don't have to re-create it every time I have to show it. I was hoping that if I just call the
setDisabledDays(...)
method and set the disabled dates, the new dates passed would overwrite the previous values and be disabled.So when calling
datePickerDialog.setDisabledDays(disabledDays.distinct())
, it is working as expected for the first selection, but for the next selection, when it is called again on the same DatePickerDialog instance, the new dates are added to themDefaultLimiter.disabledDays
set.Currently the only way to avoid this issue is to create a new
DatePickerDialog
instance everytime we need it, but an other alternative (using the same instance) can be:Inside the
DefaultDateRangeLimiter
class, we have:For me, the method name is a bit confusing, because it "adds" the disabled dates to the already existing list, instead of setting it.
My suggestion is to add a new method to replace the disabled dates like this:
I think a method like
addDisabledDates(...)
can be more right for the users to know that the dates are being added, not replaced, So we can move the logic ofsetDisabledDates()
method toaddDisabledDates()
, call the latter from the former, and deprecate the former method.