-
Notifications
You must be signed in to change notification settings - Fork 172
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
Doubletap/click couses trouble on Android. #75
Comments
Hi, In this case you can disable the button until the navigation has finished. Not much was can build into the Framework for this case. |
Thanks. I see this is a Xamarin bug. Simple isPushing flag, would help in most cases, and a Interlock way probably fix it all together (however I am not sure what the impact on performance would be, especially on ARM). I would probably just override the PushPage of the FreshNavigationContainer with som guarding code, until Xamarin fixes this. |
Yes we will look into this, or accept a PR. |
This seems to work for my case, however it will ignore all other PushPage events until the one executing is finished.
Edit: != changed to ==, see: https://msdn.microsoft.com/en-us/library/d3fxt78a(v=vs.110).aspx |
Looks like others have the same problem (this from 2014): https://forums.xamarin.com/discussion/18184/bug-in-xamarin-forms-navigationpage-for-android |
So I have looked a little on this one, and thought about some possible solutions. And I also see that this is a problem on iOS, but normally you won't see it as the view gets "locked". I think the best way to solve this is to create a custom command from ICommand, and implement a way to create these commands from CoreMethods. This will probably be the safest way. And it will be backward compatible. I have created some example code on: https://github.com/oddbear/DoubleTapTest The only thing a developer needs to do, is change void to Task in the command logic, create a shared object (or reuse the commands, with parameters for execution), and use the ICommand interface instead of Command or Command. Other commands can also be created, but then there must be some setup/configuration logic. |
@oddbear Looks good, could you package into the FreshMvvm core and do a pull request? |
I am working on a branch now: https://github.com/oddbear/FreshMvvm/tree/feature/navigation-command I am not 100% sure about the naming, and if using the CoreMethod directly is the best ide (as you cannot do this in the constructor, but need to use the init method). |
Great work, look forward to the PR. It will solve the issue for many people. |
Pull request #99 |
@oddbear would that PR resolve the issue in which two pages are added to the navigation stack when a button is pressed twice in rapid succession? I'm having that problem currently and I'm figuring out the best way of solving this. |
@joanbarros the PR itself does not fix anything like that, but adds a couple of "command" you optional can use as a workaround. The implementation for ignoring would be like:
PR Implementation: PR Example of usage: This would probably still work, but I have not tested it for a while. The important part is to await the push. Now if there has been any changes so the await is a await for the push to stack, and not show pages, then this would need some additional logic, but should be feasible. If you have any issues, I would gladly help. |
@oddbear gotcha, thnx. That's what I got from reading the code but was not completely sure if something else needed to be done in the framework end. I'll try this workaround. It seems to solve my issue rather easily. |
I think that it's better to generalize the problem for disabling the command during any async process by implementing AsyncCommand. There are several implementations of this pattern, we used this as a base for our solution. |
@danielkatz Nice. This seems like a great solution, and actually quite similar to the PR. It has a interesting approach to solve the "sharelock" issue also (through the ExecuteSubmitAsync, CanExecuteSubmit), that is, if you press one button, then immediately another button. Therefor a shared state between the commands is needed to not allow this. I guess the biggest difference would be that the AsyncCommand is more Xamarin.Forms focused, and probably easier and more familiar to work with. While the approach in the PR is probably easier if you need that extra level of control, or also use it outside of XF. |
Problems with double click/tap on binded navigation commands.
Ex.
Can be reproduced in the FreshMvvmSampleApp.Droid project on Nexus 5 (lollipop) emulator (mac os x).
"Basic Navigation" -> 2x click on Quotes.
Opens the Quotes page 2 times. Two pages is put on the stack, before the application navigates to the one of them.
(I have the same problem on my testapp on a physical Nexus 5X)
Clicking on the ADD button (ex. on Master detail page) like a maniac, crashes the app with NullReferenceException.
The text was updated successfully, but these errors were encountered: