Reputation: 11469
I have a thread running showing some stuff, but there is also a onTouch event, what I want to do is to lock the OnTouch while the other Thread is running and when it is done then allow the OnTouch to work again..?
How can I achieve this?
Thank you
Upvotes: 1
Views: 261
Reputation: 52249
I would use a flag that indicates if a thread is running. Then you can do this in your onTouch method:
public boolean onTouch(View v, MotionEvent event) {
if (!threadIsRunning) {
//do you stuff here
}
}
And in your thread you can set the flag in the run method:
public void run() {
isThreadRunning = true;
}
As soon as your thread is finished, you set the flag back to false:
isThreadRunning = false;
Upvotes: 2
Reputation: 9300
return false
if a thread is running on onTouchListener and True
if all thread job is done.
Upvotes: 1