Created CLV to display media files (gif, jpg, png, pdf) and their names.
Works well, but the loading time for all files is more than 3 seconds.
Please help with using Lazy loading. How should I change my code?
Thanks!
B4X:
Sub Process_Globals
Private xui As XUI
End Sub
Sub Globals
Private CLV1 As CustomListView
Private ImView As B4XView
Private lblTitle As B4XView
Dim folder As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim media As ClassMedia
Dim filename As String
Dim n As Int
Activity.LoadLayout("1")
For Each k As String In parser.db.media.Keys
If parser.db.media.ContainsKey(k) Then
media=parser.db.media.Get(k)
n=media.mediaFile.LastIndexOf2("\",media.mediaFile.Length-1)
filename=media.mediaFile.SubString(n+1)
If media.form="PDF" Then
filename="pdf.png"
folder=File.DirAssets
Else
folder=Starter.myFolder
End If
CLV1.Add(CreateItem(CLV1.AsView.Width, media.titl, filename), "")
End If
Next
End Sub
Private Sub CreateItem(Width As Int, Title As String, Image As String) As Panel
Dim p As B4XView = xui.CreatePanel("")
Dim height As Int = 50dip
p.SetLayoutAnimated(0, 0, 0, Width, height)
p.LoadLayout("Card1")
lblTitle.TextSize=Starter.TextSize
lblTitle.Text = Title
ImView.SetBitmap(xui.LoadBitmapResize(folder, Image, ImView.Width, ImView.Height, True))
Return p
End Sub
Please help with using Lazy loading. How should I change my code?
Thanks!