Hey,
i took the project from here:
i have edited it to get all the images of a folder back, but when i scroll now there is a lag, it does not feel smooth.
Got any tips on how I can fix this?
The Image folder has 1k images.
Thanks
i took the project from here:
Grid Class - PreoptimizedCLV
Grid using Erel sample code based on PreoptimizedCLV -> https://www.b4x.com/android/forum/threads/grid-class-preoptimizedclv.116309/#post-726808 Example applied on F1, Work very nice: The idea of this class is to be able to load in a 3 column Grid (customizable) a long list of url images...
www.b4x.com
Got any tips on how I can fix this?
The Image folder has 1k images.
Thanks
modifyied Type:
Type MyImageData (IndexOfFirstImage As Int,lst_image_path As List)
Get Files and create list:
Dim path As String = File.DirRootExternal & "/Snapchat"
Wait For (File.ListFilesAsync(path)) Complete (Success As Boolean, Files As List)
If Success And Files.IsInitialized Then
For i = 1 To Files.Size Step 4
Dim tmp_lst As List
tmp_lst.Initialize
For z = 0 To 3
If i + z < Files.Size Then
tmp_lst.Add(File.Combine(path, Files.Get(i + z)))
End If
Next
PCLV.AddItem(150dip, xui.Color_White, CreateMyImageData(i,tmp_lst))
Next
PCLV.ShowScrollBar = False 'no fast scrolling
PCLV.ExtraItems = 5
PCLV.Commit
Else
Log("error")
End If
CustomListView1_VisibleRangeChanged:
Sub CustomListView1_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
Dim item As CLVItem = CustomListView1.GetRawListItem(i)
Dim pnl As B4XView = xui.CreatePanel("")
item.Panel.AddView(pnl, 0, 0, item.Panel.Width, item.Panel.Height)
Dim data As MyImageData = item.Value
'Create the item layout
pnl.LoadLayout("Item")
For i = 0 To 3
pnl.GetView(0).GetView(i + 4).Text = data.IndexOfFirstImage + i
SetImage(data.lst_image_path.Get(i), pnl.GetView(0).GetView(i))
Next
Next
End Sub
SetImage:
Sub SetImage(path As String, ImageView As B4XView)
Try
If ImageView.Parent.Parent.IsInitialized Then
Dim bmp As B4XBitmap = xui.LoadBitmapResize(path,"",ImageView.Width,ImageView.Height,True)
ImageView.SetBitmap(bmp)
End If
Catch
Log(LastException)
End Try
End Sub
CreateMyImageData:
Public Sub CreateMyImageData (IndexOfFirstImage As Int,lst_image_path As List) As MyImageData
Dim t1 As MyImageData
t1.Initialize
t1.IndexOfFirstImage = IndexOfFirstImage
t1.lst_image_path = lst_image_path
Return t1
End Sub