HttpUtils and JobDone (Bitmap D/L)

pixelpop

Active Member
Licensed User
Longtime User
I am stumped on how HttpUtils handles multiple bitmap downloads. Here is a sample snippet:

B4X:
Sub GetImages

For indexCnt = 0 To 9
   Dim ImageJob As HttpJob
   ImageJob.Initialize("SmImageJob", Me)
   ImageJob.Download("http://somelocation/distribution/media/bitmap" & indexCnt & ".jpg")
Next

End Sub

Sub JobDone (Job As HttpJob)

   If Job.Success = True Then
      ImageBmp(x) = Job.GetBitmap
   End If

End Sub

where ImageBmp is a 10-element array of bitmaps.

In practice, all 10 of the "ImageJob.Download" commands will execute before the JobDone is raised (or are they?). So does JobDone have some sort of download "que" whereby all 10 downlaods are performed and then JobDone is raised and all 10 downloads are assigned to ImageBmp(x) in the correct order? Or maybe I am just complete off. I'm trying to acheive an end result where 10 different bitmaps can be downloaded from 10 different URLs, then each of those bitmaps can be assigned to the ImageBmp array in the proper order.
 

pixelpop

Active Member
Licensed User
Longtime User
Actually, FlickrViewer was what prompted me to ask the question. I set a counter (imcnt) immediately after the download command (declared as Int and initialed to 0 in Activity_Create:

ImageJob.Download(m.Group(1))
imcnt = imcnt + 1

And then break on JobDone:

Sub JobDone(Job As HttpJob)
Select Job.JobName
...
Case "ImageJob"
{break} ImagesJobDone(Job)

When the app breaks and the counter value is examined, it is equal to 9. In my mind, that means the download command executed 9 times before JobDone was raised. Please clarify my thinking on this. Thanks.
 
Upvote 0

pixelpop

Active Member
Licensed User
Longtime User
You have a note in the FlickrViewer example:

B4X:
'Usually we will want to have a single JobDone sub for all jobs.
'This allows us to check HttpUtils.Complete flag in Activity_Resume (as shown above).

However, you do not show the HttpUtils.Complete flag in Activity_Resume in your FlickrViewer example. Assuming that this flag is raised when all the jobs in the image que have been completed, could you provide an example of how this flag is used?
 
Upvote 0
Top