I have this project that works properly downloading and saving a zip file..
What I would fail to implement a progress bar to show the user.
I help?
What I would fail to implement a progress bar to show the user.
I help?
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private btnDownload As Button
Private lbState As Label
Private progress1 As Node
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
Dim res As String
res = Job.GetString
Log("JobName: "&Job.JobName&" / Tag = "&Job.Tag)
If Job.JobName = "DownloadFILE" Then
' Thats the name of this special download we created using the Tag-Property
Dim OutStream As OutputStream
Log("DownloadReady: "&Job.Tag)
OutStream = File.OpenOutput(File.DirApp , "DBUtils.zip", False) ' Job.Tag is read to set the Original Filename we specify earlier in the creation of the Job
File.Copy2(Job.GetInputStream,OutStream) ' save the file
OutStream.Close
Log(Job.Tag&" are written to "&File.DirApp) ' Write the Originalname to the log to see what happens ;-)
Else
' ToastMessageShow(Job.JobName&": " & Job.GetString, True)
End If
Else
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub btnDownload_Action
Dim job As HttpJob
Dim dummy As String
btnDownload.Enabled=False
dummy = "http://www.misimagenesgratis.com.ar/DBUtils.zip"
job.Initialize("DownloadFILE", Me)
job.Tag = dummy ' The filename are stored in the "Tag"-Property of the job so later you can "read" the filename from the Tag
job.download(dummy)
progress1.Visible=True
End Sub