hello experts I'm looking in the forums to clear a doubt and I can not find an answer.
with this code I download images from the server but I do not know how to fit it to my code.
i use VisibleRangeChanged to load my customlistview
where I insert the code ImageDownloader?, what is the correct and optimized way? any help
with this code I download images from the server but I do not know how to fit it to my code.
B4X:
links.Put(img2, "http://www.miweb.com/solodomi/aliados/"&id_emp&"/productos/"&cd.id&".png")
CallSubDelayed2(ImageDownloader, "Download", links)
i use VisibleRangeChanged to load my customlistview
B4X:
Private Sub CreateItem(Width As Int, Title As String, id As String, nombre As String, descripcion As String, precio As String, items As String )
Dim p As B4XView = xui.CreatePanel("")
Dim height As Int = 155dip
If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then height = 170dip
Dim cd As CardData
cd.Initialize
cd.Title = Title
cd.id = id
cd.nombre = nombre
cd.descripcion = descripcion
cd.precio = precio
cd.items = items
p.SetLayoutAnimated(0, 0, 0, Width, height)
CLV.Add(p, cd)
End Sub
B4X:
Sub CLV_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim ExtraSize As Int = 20
For i = 0 To CLV.Size - 1
Dim p As B4XView = CLV.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
'visible+
If p.NumberOfViews = 0 Then
Dim cd As CardData = CLV.GetValue(i)
p.LoadLayout("CellItem2")
lblnombre.Text = cd.nombre
lbldescripcion.Text = cd.descripcion
lblprecio.Text = cd.precio
If miclase.pantalladip = "Gama-baja" Then
lblnombre.TextSize = 10
lbldescripcion.TextSize = 9
lblprecio.TextSize = 13
lblpeso.TextSize = 12
End If
ImgCpanel.SetBackgroundImage(LoadBitmapSample(File.DirAssets,"PnlProdMesa.png",25%x,25%y))
btnmas.Tag = cd.id & "-" & cd.nombre & "-" & cd.descripcion & "-" & cd.precio & "-" & cd.items
img2.Tag = cd.id & "-" & cd.nombre & "-" & cd.descripcion & "-" & cd.precio & "-" & cd.items
img2.Visible = True
'CallSubDelayed2(ImageDownloader, "Download", links)
fuente
End If
Else
'Not visible
If p.NumberOfViews > 0 Then
p.RemoveAllViews
End If
End If
Next
End Sub
where I insert the code ImageDownloader?, what is the correct and optimized way? any help