Sub Download (ImageViewsMap As Map)
For i = 0 To ImageViewsMap.Size - 1
tasks.Put(ImageViewsMap.GetKeyAt(i), ImageViewsMap.GetValueAt(i))
Dim link As String = ImageViewsMap.GetValueAt(i)
If cache.ContainsKey(link) Then
Dim iv As ImageView = ImageViewsMap.GetKeyAt(i)
SharedCode.FitCenterBitmap(iv, cache.Get(link))
Else If ongoingTasks.ContainsKey(link) = False Then
ongoingTasks.Put(link, "")
Dim jobHttpGetImage As HttpJob
jobHttpGetImage.Initialize(link, Me)
jobHttpGetImage.Download(link) 'raises ResponseError error with Reason: Not Found, and Response text
Wait For (jobHttpGetImage) JobDone(j As HttpJob)
If j.Success Then
Dim bmp As Bitmap = j.GetBitmap
cache.Put(j.JobName, bmp)
If tasks.IsInitialized Then
For i = 0 To tasks.Size - 1
Dim link As String = tasks.GetValueAt(i)
If link = j.JobName Then
Dim iv As ImageView = tasks.GetKeyAt(i)
SharedCode.FitCenterBitmap(iv, bmp)
End If
Next
End If
Else
Log("ImageDownloader Error")
End If
j.Release
End If
Next
End Sub