At the push of a button the application tries to send a data to a server. If the connection is active, the data is immediately sent, but if the link is down, the system attempts to send for x seconds. In fact, in that period of time, the interface is (intentionally) blocked (the button is illuminated to highlight the current operation). The problem is that if the user starts to press other buttons, the events are heard and when the connection becomes active, it performs all the operations related to those events.
How can I prevent it?
How to prevent that How to prevent each event related to other buttons to be processed?
Any suggestions would be very appreciated.
EDIT I've already tried to check a flag when the button is pressed, unfortunately when the flag is re-setted, all events are catched and executed:
public void onClick(View v) {
switch(v.getId())
{
case R.id.button1: //when sendData() is trying to send the message, I don't want to that this code is executed
if(flagConf == 1)
{
...do something...
}
break;
case R.id.buttonConfirm:
if(myFlag == 1) //to avoid multiple touch of this button
{
...do something...
myFlag = 0;
sendData();
if(dataSent)
...do something...
else
...do something...
myFlag = 1; //I set this flag to 1 because, if message is not sent, the user have to re-pressed the buttonConfirm and try again
}
break;
}
}
And on other button listeners:
Thanks