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

Issue 1332: Multiple numeric dialogs appearing #1356

Merged

Conversation

kalina559
Copy link
Collaborator

Resolves #1332.
I'm not sure about this solution though, as it's a bit of a hack. The bug itself is not that serious - users can just enter the data twice, it's not breaking the app or anything. What do you think @iSoron @hiqua ?
While working on it I also noticed that the issue appears when clicking on the tiles in ListHabitsScreen, I corrected this there as well. Numeric dialog is also shown when using a Checkmark widget, but the issue wasn't appearing there.

@iSoron
Copy link
Owner

iSoron commented Apr 21, 2022

Thanks for tackling this bug, @kalina559. I agree it's not serious, but it would still be nice to fix it.

I think keeping track of the number picker visibility in NumberPickerFactory is problematic. For example, if, for any reason, onDismissListener does not get called, we would get stuck in a state where the number picker can no longer be shown until the app is restarted.

I would suggest the following instead. Whoever calls NumberPickerFactory(...).create should keep a reference to the dialog, and should dismiss it before showing a new one. Something like this:

if (currentPicker != null) currentPicker.dismiss()
currentPicker = NumberPickerFactory(this@ShowHabitActivity).create(value, unit, notes, dateString, frequency, callback)
currentPicker.show()

@kalina559
Copy link
Collaborator Author

I made something between the initial solution and the one you described - we're keeping a reference in a companion object of
NumberPickerFactory and we dismiss it when create() is called to create a new dialog. This way we avoid writing almost identical code in both ListHabitsScreen and ShowHabitActivity.

The only downside to that is that users can see the first dialog for a split second before it gets dismissed. In the first solution the second dialog was prevented from being created if another one already existed, so the UX was a bit better.

Copy link
Owner

@iSoron iSoron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that also works. I only have one comment below. Other than that, the PR looks fine to me.

@kalina559 kalina559 requested a review from iSoron April 22, 2022 18:44
@kalina559
Copy link
Collaborator Author

Hey @iSoron, can I merge this?

@iSoron iSoron merged commit 9d4161a into iSoron:dev May 2, 2022
@iSoron
Copy link
Owner

iSoron commented May 2, 2022

@kalina559 I've merged it, thanks!

@kalina559 kalina559 mentioned this pull request Aug 13, 2022
10 tasks
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.

Multiple numeric dialogs appear after double clicking calendar tiles
2 participants