1. First determine whether there is a network. If the network is unavailable, return directly 2. Filter repeated clicks 3. If you hope that new requests will not be triggered before the previous request is returned, you can set a status flag
When the user clicks the button for the first time, a friendly prompt interface is given: such as diaolg, which prompts the user to wait for data to be returned. Otherwise, in terms of user experience, there is no response when I click the button, and I will keep clicking. Hope it helps you.
As mentioned above, a network framework must be used in this situation. Volley is indeed very suitable. I recommend the Volley source code analysis I wrote. I hope it will be helpful to you: https://github.com/wangzhengy...
After clicking the button, the button will be made non-clickable. If possible, the dialog being requested will pop up. After requesting the data, the dialog will be canceled and the button will be made clickable.
You can set the time interval between two clicks. If it is less than a certain period of time, the second click will not respond
1. First determine whether there is a network. If the network is unavailable, return directly
2. Filter repeated clicks
3. If you hope that new requests will not be triggered before the previous request is returned, you can set a status flag
When the user clicks the button for the first time, a friendly prompt interface is given: such as diaolg, which prompts the user to wait for data to be returned.
Otherwise, in terms of user experience, there is no response when I click the button, and I will keep clicking.
Hope it helps you.
Use thread pool to limit the maximum number of threads.
You cannot initiate network requests for the same URL at the same time
Caching
Volley can do all the above
As mentioned above, a network framework must be used in this situation. Volley is indeed very suitable. I recommend the Volley source code analysis I wrote. I hope it will be helpful to you: https://github.com/wangzhengy...
After initiating the request, the Click event of the Button is blocked and restored after the request is completed.
After clicking the button, the button will be made non-clickable. If possible, the dialog being requested will pop up. After requesting the data, the dialog will be canceled and the button will be made clickable.
Write a judgment. Set a flag, TAG = false; if (!TAG) {//execute}
When turned on, TAG = true;