Sub JobDone(Job As HttpJob)
Dim ss As String
ongoingTasks.Remove(Job.JobName)
If Job.Success Then
Dim bmp As Bitmap = Job.GetBitmap
cache.Put(Job.JobName, bmp)
If tasks.IsInitialized Then
For i = 0 To tasks.Size - 1
Dim link As String = tasks.GetValueAt(i)
If link = Job.JobName Then
Dim iv As ImageView = tasks.GetKeyAt(i)
ss= link.SubString(link.Length-15)
Dim out As OutputStream = File.OpenOutput(File.DirInternal, ss, False)
File.Copy2(Job.GetInputStream, out)
out.Close '<------ very important
Log("close " & ss)
iv.SetBackgroundImage(bmp)
Dim lbl As B4XView = Sender
lbl.SetBitmap(LoadBitmap(File.DirAssets,"buttons_PNG163.png"))
End If
Next
End If
Else
Log("Error downloading image: " & Job.JobName & CRLF & Job.ErrorMessage)
End If
Job.Release
End Sub