Not so much a class per se but it seems a few people were after this based on this thread. Feel free to move this to somewhere more appropriate if need be.
Here's an example of usage:
To activate the progress bar you have to set HttpUtils2Service.progressSub with your update callback sub as well as setting HttpUtils2Service.timerInterval (int in ms). If HttpUtils2Service.progressSub = "" then HttpUtils2 runs as normal.
Bear in mind you have to use the modified HttpUtils2Service.bas and HttpJob.bas included in the zip. You can't just copy and paste the above code.
Here's an example of usage:
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim pro As ProgressBar
pro.Initialize("pro")
Dim cmdSubmit As Button
cmdSubmit.Initialize("cmdSubmit")
cmdSubmit.Text = "Submit"
HttpUtils2Service.progressSub = "downloadProgress"
HttpUtils2Service.timerInterval = 200
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.AddView(pro,5dip,5dip,100%x-10dip,20dip)
Activity.AddView(cmdSubmit, 5dip, 30dip, 100%x-10dip,50dip)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub downloadProgress(tmp As ProgressStatus)
Log(tmp.Downloaded & "/" & tmp.Total)
pro.progress=Round((tmp.downloaded*100)/tmp.total)
End Sub
Sub cmdSubmit_Click
Dim jobPost As HttpJob
jobPost.Initialize("JobPostName",Me)
jobPost.Download("http://ipv4.download.thinkbroadband.com/5MB.zip")
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "JobPostName"
ToastMessageShow("Success!", True)
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
To activate the progress bar you have to set HttpUtils2Service.progressSub with your update callback sub as well as setting HttpUtils2Service.timerInterval (int in ms). If HttpUtils2Service.progressSub = "" then HttpUtils2 runs as normal.
Bear in mind you have to use the modified HttpUtils2Service.bas and HttpJob.bas included in the zip. You can't just copy and paste the above code.