Improves flexibility of Date and Time DialogFragmentDelegates #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The way
DatePickerDialogFragment
,DatePickerDialogFragmentCompat
,TimePickerDialogFragment
, andTimePickerDialogFragmentCompat
haveonCreateDatePickerDialogFragmentDelegate
andonCreateTimePickerDialogFragmentDelegate
defined asprotected
methods, indicates they were designed to allow subclasses to override those methods to alter the dialog.However, the delegates themselves (
DatePickerDialogFragmentDelegate
andTimePickerDialogFragmentDelegate
) have their pickers (DatePicker
andTimePicker
), as well as their listeners (OnDateSetListener
andOnTimeSetListener
), defined asprivate
.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 overridesetOnTimeSetListener
, as well as the need to find theDatePicker
andTimePicker
ononCreateDialogView
.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
andOnTimeSetListener
from delegates.Since
DialogFragment
overrides someDialog
listeners (likeOnCancelListener
orOnDismissListener
) it might be useful to accessOnDateSetListener
orOnTimeSetListener
directly from theDialogFragment
.Edit (after
9a27bf5
):Changes
mDelegate
visibility on allDialogFragments
, to avoid the need to overrideonCreateDatePickerDialogFragmentDelegate
andonCreateTimePickerDialogFragmentDelegate
.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.