Now the downloading files from Internet is very simple due to Wait For.
B4X:
Sub DownloadImage(Link As String, iv As ImageView)
If InterruptDownloadingFlag Then Return 'stop, no more !
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If InterruptDownloadingFlag Then Return 'stop !!!
If j.Success Then
iv.Bitmap = j.GetBitmap
End If
j.Release
End Sub
But if at Activity opening a loop starts 50... 100 times downloading some _optional_ for user files to be listed, if he wants. Again - files are just for optional viewing...
Downloading can be rather long, if many files... and depends on the Internet speed...
But if the user decided to go BACK, closing the Activity - now it's impossible ! As Activity re-started again.
Boolean flag in the downloading sub does not help.
If 5-10 files to be downloaded - it's OK, downloadings are finished fast.
The issue you encounter is not related to Wait For. It is related to HttpUtils2 behavior. It internally uses CallSubDelayed when the result is available and CallSubDelayed causes the activity to be resumed.
The solution is to make all requests from a service. Put this sub in the starter service and call it with CallSubDelayed3.
Yes, checked. Prev activity is slow while downloadings are working...
It means that in this case - the async downloading lot of images is a wrong way...
And ULV cannot help , as here horizontal scrollview must be used, by design.
The downloading step should not affect the performance. Loading many images can be slow. The first step is to use Job.GetBitmapSample instead of Job.GetBitmap.