-
-
Notifications
You must be signed in to change notification settings - Fork 946
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
Possibility to select year only #237
base: master
Are you sure you want to change the base?
Conversation
I'll have to see how this looks. Based on the code I'm not sure You could also just use a dropdown ;-) |
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.
I still need to actually try the code, but I've already added a few comments
@@ -295,6 +299,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); | |||
} | |||
|
|||
if (mShowYearOnly) { |
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.
Rather than removing these views, set their visibility to GONE.
This avoids potential NullPointerExceptions
when other pieces of the code try to fetch them
@@ -576,6 +585,13 @@ public void showYearPickerFirst(boolean yearPicker) { | |||
mDefaultView = yearPicker ? YEAR_VIEW : MONTH_AND_DAY_VIEW; | |||
} | |||
|
|||
public void showYearOnly(boolean yearOnly) { | |||
mShowYearOnly = yearOnly; | |||
if (yearOnly) { |
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 will fail if someone later set showYearPickerFirst to false
You'll have to change the setter for showYearPickerFirst too
mShowYearFirst = yearOnly || showYearFirst;
You'll also have to add some logic to the sample app that takes this paired logic into account. (would be great if android had some nice way to do reactive UIs, but there you go)
I have a case where I only need to track user's birthyear, so month and day controls are not useful to me. I made it possible to only display the year picker view.