-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Create DatePickerDialog on demand
#25363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hey there @OvrBtn! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
DatePickerDialog on demandDatePickerDialog on demand
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Failing tests don't seem related. |
mattleibow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR has some good things, but I feel like it is working with bad source code. Maybe check to see if the whole dialog can be created on demand when it is about to appear.
| internal DatePickerDialog? DatePickerDialog { get { return _dialog; } } | ||
| internal DatePickerDialog? DatePickerDialog { get { return _dialog ??= CreateDefaultDatePickerDialog(); } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just create the dialog in ShowPickerDialog like the time picker? I also see that in time picker, we always re-create the dialog:
void ShowPickerDialog(int hour, int minute)
{
_dialog = CreateTimePickerDialog(hour, minute);
_dialog.Show();
}I see we do set some values in the mappers for the min/max dates, but I feel like that was wrong as we can totally set this in the setDateLater part of the ShowPickerDialog just like we set the actual date.
I think this whole setup should rather be a lazy loading thing and we set the min/max when the picker is about to appear.
| if (VirtualView != null) | ||
| { | ||
| dialog.DatePicker.MaxDate = (long)VirtualView.MaximumDate.ToUniversalTimeNative().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds; | ||
| dialog.DatePicker.MinDate = (long)VirtualView.MinimumDate.ToUniversalTimeNative().Subtract(DateTime.MinValue.AddYears(1969)).TotalMilliseconds; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, maybe no need to the setLater as you do it here. In this case, we can use a totally lazy creating.
Description of Change
This PR is an addition to #24948 and it further improves performance of first render of
DatePickerby creatingDatePickerDialogon demand instead of on control render.Issues Fixed
Fixes #24929
Blockers
This PR should be merged after #20547 is merged since it might break workarounds like this one #12899 (comment)