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

Fix timePicker minutes always set to current time #893

Merged
merged 1 commit into from
Jan 7, 2024
Merged

Conversation

Altonss
Copy link
Collaborator

@Altonss Altonss commented Dec 6, 2023

This PR fixes issue #890.

@cla-bot cla-bot bot added the cla-signed ✔️ The Contributor Licence Agreement was signed by all contributors. label Dec 6, 2023
@Altonss Altonss linked an issue Dec 6, 2023 that may be closed by this pull request
@Altonss Altonss requested a review from ialokim December 6, 2023 00:33
@ialokim
Copy link
Collaborator

ialokim commented Jan 4, 2024

Thanks for the fix! Could you elaborate here (or even better add a comment) as to why this fixes the issue? Maybe a link to the timePicker Android docs?

Please also squash your commits into one for them to be merged.

@Altonss
Copy link
Collaborator Author

Altonss commented Jan 4, 2024

There was a strange bug, with using this code because it was only a reference to a variable that is reset when changing either hour or minute:

timePicker.currentHour = c.get(HOUR_OF_DAY)
timePicker.currentMinute = c.get(MINUTE)

So I replaced this part and cared about deprecated methods, see : https://developer.android.com/reference/android/widget/TimePicker#setCurrentHour(java.lang.Integer)

@ialokim
Copy link
Collaborator

ialokim commented Jan 4, 2024

Hum sorry I still don't get it. Is it a known issue with the deprecated setCurrent{Hour,Minute}() methods on API higher than 23, or what variable was reset when changing either hour or minute?

@Altonss
Copy link
Collaborator Author

Altonss commented Jan 4, 2024

Hum sorry I still don't get it. Is it a known issue with the deprecated setCurrent{Hour,Minute}() methods on API higher than 23, or what variable was reset when changing either hour or minute?

Sorry if I wasn't clear. There are 2 diffirent issues here:

  1. The main issue: the c calendar variable gets reset when setting either hour or minute for timePicker. I fixed it by saving the values of the c variable before setting timePicker.
  2. the deprecated API used for setCurrent which isn't really an issue, I just cleaned the code for the future.

@ialokim
Copy link
Collaborator

ialokim commented Jan 7, 2024

1. The main issue: the c calendar variable gets reset when setting either hour or minute for timePicker. I fixed it by saving the values of the c variable before setting timePicker.

Ah, now I got it - I looked at the surrounding code and found the TimeChangedListener that updates the calendar. Nice catch!

2. the deprecated API used for setCurrent which isn't really an issue, I just cleaned the code for the future.

Thanks for that too.

@ialokim ialokim merged commit c9aaa93 into master Jan 7, 2024
3 of 4 checks passed
@ialokim ialokim deleted the fix-timePicker branch January 7, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed ✔️ The Contributor Licence Agreement was signed by all contributors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TimePicker minutes are always set to current time
2 participants