user710502
user710502

Reputation: 11469

Android Lock OnTouchListener

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

Answers (2)

RoflcoptrException
RoflcoptrException

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

weakwire
weakwire

Reputation: 9300

return false if a thread is running on onTouchListener and True if all thread job is done.

Upvotes: 1

Related Questions