0

I'm a newbie in android and it seems to be simple, but I have following app structure.

App has button in main activity (which became disabled after click) and two tab fragments.

Active tab fragment run approx 20 threads via model-class.

So only model-class knows when all threads finished, but using view element in model is awful decision.

How to enable button after all background threads finished?

Timeout is bad choice, because no one knows on what device code will be performed and it can takes some time. Thread.join() or wait() hangs ui in my case.

Appreciate for any suggestions. I can provide code if it's necessary, but question seems to be general.

Nick Juelich
  • 428
  • 2
  • 13
white-imp
  • 313
  • 2
  • 16

1 Answers1

1

You should create a new Interface that works as Listener that listens to the event of threads in the model-class

Or

Using callBack() to notify the MainActivity when the threads finished to set back the button enable. To create a new Listener please refer to this Question:

How to create our own Listener interface in android?