Skip to content
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

Improves flexibility of Date and Time DialogFragmentDelegates #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jpmcosta
Copy link
Contributor

@jpmcosta jpmcosta commented Feb 27, 2017

The way DatePickerDialogFragment, DatePickerDialogFragmentCompat, TimePickerDialogFragment, and TimePickerDialogFragmentCompat have onCreateDatePickerDialogFragmentDelegate and onCreateTimePickerDialogFragmentDelegate defined as protected methods, indicates they were designed to allow subclasses to override those methods to alter the dialog.

However, the delegates themselves (DatePickerDialogFragmentDelegate and TimePickerDialogFragmentDelegate) have their pickers (DatePicker and TimePicker), as well as their listeners (OnDateSetListener and OnTimeSetListener), defined as private.

This choice was probably an oversight on my part, as I think I never actually needed to override them. However, that choice makes it (while still possible) somewhat troublesome to override the delegates to alter the dialog builder.

I think that changing their visibility to protected would make sense, as it would avoid the need to override setOnTimeSetListener, as well as the need to find the DatePicker and TimePicker on onCreateDialogView.

Note: I want to add a negative button to the dialog, and that would help a lot. 😄

Edit (after 0d232a9):
Adds methods to get OnDateSetListener and OnTimeSetListener from delegates.
Since DialogFragment overrides some Dialog listeners (like OnCancelListener or OnDismissListener) it might be useful to access OnDateSetListener or OnTimeSetListener directly from the DialogFragment.

Edit (after 9a27bf5):
Changes mDelegate visibility on all DialogFragments, to avoid the need to override onCreateDatePickerDialogFragmentDelegate and onCreateTimePickerDialogFragmentDelegate.

Summary:
This PR is not so much about giving access, but more about making the access easier, as every component could already be accessed before, but it was just harder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant