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

Possibility to select year only #237

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

Possibility to select year only #237

wants to merge 3 commits into from

Conversation

dehy
Copy link

@dehy dehy commented Sep 13, 2016

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.

@wdullaer
Copy link
Owner

I'll have to see how this looks. Based on the code I'm not sure

You could also just use a dropdown ;-)

Copy link
Owner

@wdullaer wdullaer left a 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) {
Copy link
Owner

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) {
Copy link
Owner

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)

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.

2 participants