A
A
artem2022-03-26 20:08:34
Android
artem, 2022-03-26 20:08:34

How to prevent double tap + firebase?

623f47a70c1fd936222180.jpeg

I implement the entrance to the application through firebase (all work with data in the ViewModel), I use NavController for navigation. Double click problem, when I press the login button and immediately (quickly) the register button, it crashes (Navigation action/destination cannot be found from the current destination).

I found an article https://stackoverflow.com/questions/51060762/illeg...
, which describes the solution, but in my case it can take more than a second or less between clicks, it all depends on the response from the database.

I made a function that blocks all buttons when you click on one until the end of the operation in the coroutine.
I pass a function from the fragment class to a function parameter from the view model, which calls a function from the model where the data is taken from the firebase, at the end of the download I turn on the buttons with that function, if it was not possible to enter, if I succeeded, then I start the navigation, after which I turn on the buttons

What will be more right?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question