Fixes #17864 : Instant card, Double Pop of Discard Dialog Box issue#17871
Fixes #17864 : Instant card, Double Pop of Discard Dialog Box issue#17871MritunjayTiwari14 wants to merge 7 commits intoankidroid:mainfrom
Conversation
|
@david-allison I need some guidance on how to fix the swipe gesture with back button which simultaneously pop and closes the discard dialog box without any interaction with the user |
|
@MritunjayTiwari14 I'm marked as busy on GitHub and won't be able to help, sorry |
| // private val dialogBackCallback = | ||
| // object : OnBackPressedCallback(false) { | ||
| // override fun handleOnBackPressed() { | ||
| // showDiscardChangesDialog() | ||
| // } | ||
| // } | ||
|
|
||
| private var isDialogVisible = false | ||
|
|
There was a problem hiding this comment.
Heya! thanks for the contribution
Why this comment?
And how does it solve the issue, did you inspect the root cause?
There was a problem hiding this comment.
Hello!, Sorry i forgot to remove it. I kept it as a backup and to analyze it while i wrote the new code with Flag to avoid repeated call to the Function to Display Discard Dialog Box.
|
Can someone Please Review it? @david-allison |
|
Is there a simpler way to do this? This feels over complicated and likely to lead to bugs, especially for something which is such a common occurrence |
Alright, looking into it! |
| Timber.i("InstantNoteEditorActivity:: OK button pressed to confirm discard changes") | ||
| finish() | ||
| }.setOnDismissListener { | ||
| // Used Dismiss Listener to Update the Value of Flag each time the Dialog is Dismissed |
| // Used Dismiss Listener to Update the Value of Flag each time the Dialog is Dismissed | ||
| isDialogVisible = false | ||
| } | ||
| isDialogVisible = true // Updating Flag as Dialog is Visible |
There was a problem hiding this comment.
Okay removing comments!
| } | ||
| DiscardChangesDialog | ||
| .showDialog(this) { | ||
| Timber.i("InstantNoteEditorActivity:: OK button pressed to confirm discard changes") |
| private var isDialogVisible = false // Created a New Flag To Handle Double Pop up of Discard Dialog | ||
|
|
||
| private val dialogBackCallback = | ||
| object : OnBackPressedCallback(false) { | ||
| override fun handleOnBackPressed() { | ||
| showDiscardChangesDialog() | ||
| if (!isDialogVisible) { // Show Discard Dialog only when it is not Visible to avoid Duplication | ||
| showDiscardChangesDialog() | ||
| } |
|
I see there are two PR for the same issue @david-allison I am closing the latter one |
|
@criticalAY Put the SetCancelable() directly into the Activity File rather than for Whole Alertbuilder Dialog, It should be more optimized as we are changing for this Activity only and will not interfere in other places where the DiscardChangeDialog is being used otherwise. |
criticalAY
left a comment
There was a problem hiding this comment.
Quoting David:
Is there a simpler way to do this? This feels over complicated and likely to lead to bugs, especially for something which is such a common occurrence
Please see if we can do better here
|
@criticalAY Please Review, the best right now we can do is to remove the Flag and use isShowing(), other than that i have searched for many forms for hours and mostly say that to handle double back press issue, setCancellable() is a standard method. |
|
Hello???, Can anyone Please Review this? @david-allison |
|
@MritunjayTiwari14 My review comment still stands. Look into the following code, and modify it such that system swipe gestures are handled as they are by other dialogs. The problem is the root activity, not the 'discard changes' dialog |
|
Thank you for Your Direction, i was able to analyze within moments that the onBackPressed() should be called only when the motion event detects an Action.UP not Action.DOWN and that was the reason all these bugs were arising. @david-allison Please have a review over the code base. I reverted all the changes and updated the code with the simple fix. |
|
Can you please check it? @david-allison |
|
@Arthur-Milchior Can you please have a review on this? |
|
At an initial glance, this doesn't seem to take into account my comment:
|
|
Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
Purpose / Description
#17864 : Instant card, Double Pop of Discard Dialog Box issue
Fixes
Approach
using flag
How Has This Been Tested?
simply perform the task
Checklist
Please, go through these checks before submitting the PR.