Android Question how to use downloadMany with progressbar?

Leni Berry

Active Member
Licensed User
Longtime User
As described in this tutorial , especially in the example :

B4X:
Sub Activity_Create(FirstTime As Boolean)
   DownloadMany(Array("http://www.google.com", "http://duckduckgo.com", "http://bing.com"))
End Sub

Sub DownloadMany (links As List)
   For Each link As String In links
     Dim j As HttpJob
     j.Initialize("", Me) 'name is empty as it is no longer needed
     j.Download(link)
     Wait For (j) JobDone(j As HttpJob)
     If j.Success Then
       Log("Current link: " & link)
       Log(j.GetString)
     End If
     j.Release
   Next
End Sub

How to track 'wait for' until 'success' translate into progressbar?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try:
B4X:
Sub DownloadMany (links As List)
   For Each link As String In links
     Dim j As HttpJob
     j.Initialize("", Me) 'name is empty as it is no longer needed
     j.Download(link)
     Wait For (j) JobDone(j As HttpJob)
     If j.Success Then
       Log("Current link: " & link)
       Log(j.GetString)
     End If
     ProgressBar1.Progress = 100 * (links.IndexOf(link) + 1) / links.Size
     j.Release
   Next
End Sub
 
Upvote 0

Leni Berry

Active Member
Licensed User
Longtime User
Try:
B4X:
Sub DownloadMany (links As List)
   For Each link As String In links
     Dim j As HttpJob
     j.Initialize("", Me) 'name is empty as it is no longer needed
     j.Download(link)
     Wait For (j) JobDone(j As HttpJob)
     If j.Success Then
       Log("Current link: " & link)
       Log(j.GetString)
     End If
     ProgressBar1.Progress = 100 * (links.IndexOf(link) + 1) / links.Size
     j.Release
   Next
End Sub
tq so much erel
 
Upvote 0
Top