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("PanelNumber")
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 x = 0 To 3
pnl.GetView(x).GetView(1).Text = data.IndexOfFirstImage + x
MediaManager.SetMedia(pnl.GetView(x).GetView(0), $"https://picsum.photos/id/${data.IndexOfFirstImage + x}/200/300.jpg"$)
Next
Next
'The purpose of this call is to find panels that are no longer in the views tree and cancel any ongoing request that is no longer relevant.
'It also happens automatically from time to time but in this case, as many requests are sent frequently, it is better to force it to trim the cache.
'Note that you need to add HU2_PUBLIC to the build configuration.
MediaManager.TrimMediaCache
End Sub