iOS Question Downloader check success

David Meier

Active Member
Licensed User
Longtime User
Hi

I use the downloader command:

B4X:
Downloader.Initialize
    Downloader.Download(CreateMap(ivMeteo: "https://www.dorsum.ch/meteo/forecast_wu/forecast0.gif"))

Now I would like to check, whether downloading is successful or not.

Thanks for help
Cheers David
 

David Meier

Active Member
Licensed User
Longtime User
Hi Erel

Sorry for being unspecific, I meant the ImageDownloader.
B4X:
Private Downloader As ImageDownloader

Kind regards
David
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The truth is that there is no longer a good reason to use ImageDownloader as it is very simple to implement it with Wait For:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("1")
   NavControl.ShowPage(Page1)
   SetImageToImageView(ImageView1, "https://www.dorsum.ch/meteo/forecast_wu/forecast0.gif")
   SetImageToImageView(ImageView2, "https://b4x-4c17.kxcdn.com/android/forum/data/avatars/m/96/96173.jpg?1494671783")
End Sub

Sub SetImageToImageView (iv As ImageView, url As String)
   Dim j As HttpJob
   j.Initialize("", Me)
   j.Download(url)
   Wait For (j) JobDone(j As HttpJob)
   If j.Success Then
     iv.Bitmap = j.GetBitmap
   Else
     Log("Failed to load image: " & url)
   End If
   j.Release
End Sub
 
Upvote 0
Top