Sub Process_Globals
Public cache As Map
End Sub
Sub Service_Create
cache.Initialize
End Sub
public Sub Downloadimage(link As String, iv As ImageView)
If cache.ContainsKey(link) Then
Dim bmp As B4XBitmap = cache.Get(link)
If bmp.IsInitialized Then iv.SetBackgroundImage(bmp.Resize(iv.Width,iv.Height,True))
Else
Dim job As HttpJob
job.Initialize("", Me)
job.Download(link)
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Try
Dim bmp As B4XBitmap = job.GetBitmap
cache.Put(link, bmp)
iv.SetBackgroundImage(bmp.Resize(iv.Width,iv.Height,True))
Catch
log(LastException)
End Try
End If
job.Release
End If
End Sub