I need to process a few folders inside a loop, and cant give the user a feedback of the folder being processed, as all UI is only updated at the end of the loop.
The process can take a few minutes, specially because the folders are quite big and are online shared..So apparently there is no easy way to tell the user what is being processed, as I would like to.
Any trick to do update the UI while stuff is being done ?
You can do the heavy lifting in another Thread and occasionally send commands to update the UI to the Main Thread. This will require the Threading library and using Thread.RunOnGuiThread().
Divide the task into blocks and do the heavy lifting in blocks using CallSubDelayed:
B4X:
Sub HeavyLifting(block as int)
'Some heavy stuff
'....
UpdateUI
If block<MaxBlocks Then CallSubDelayed2(Me, "HeavyLifting", block+1)
End Sub
I think Roycefer solution number 2 is the best. Another solution for that is:
3. you could also write a separate jar file and execute it with jShell.RunWithOutputEvents. You can then read the _StdOut and _StdErr events and update the UI according to those raised events.