Sub clv_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim id, npics, h As Int
Dim id_title, title, datum As String
Dim p As Boolean
Dim pnl As B4XView
' FirstIndex = FIndex ' global <==== this is not working !
' LastIndex = LastIndex + FIndex
' Log("===== visible range changed from "&FirstIndex&" to "&LastIndex)
For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
Dim item As CLVItem = clv.GetRawListItem(i)
' Dim pnl As B4XView ' = xui.CreatePanel("")
id_title = item.value.As(String) ' Value is id : title instead of only id (numerical)
id = id_title.SubString2(0, id_title.IndexOf(":"))
title = id_title.Substring(id_title.IndexOf(":")+1)
'title = SQL1.ExecQuerySingleResult("SElECT title FROM entries WHERE entry_id= "& id)
datum = SQL1.ExecQuerySingleResult("SElECT datum FROM entries WHERE entry_id= "& id)
' Log("row "& i &" id= "&id&" title= "&title)
' check pictures:
npics = SQL1.ExecQuerySingleResult("SElECT count(*) FROM pictures WHERE entry_id = "& id)
' Log(npics &" pics for entry id = "& id)
If npics > 0 Then ' has pictures - no effect in lazyload !!
h = 240dip ' 240
p = True
Else
h = 120dip ' 120
p = False
End If
pnl = CreateListItem(id, title, datum, p, clv.AsView.Width, h) ' height has no influence !
pnl.Tag = title ' to use in hintrequest
item.Panel.AddView(pnl, 0, 0, pnl.Width, h)
Next
End Sub
Sub clv_ItemClick (Index As Int, Value As Object) ' value is id : title
Dim id_title As String = Value
FIndex = Index ' <==== remember when we come back
Log("---- click on Index "& FIndex)
Log("id_title = "& id_title)
curID = id_title.substring2(0,id_title.indexof(":")) ' global to give to page 2
Log("------ Click item nr "& Index &" id = "& curID)
B4XPages.ShowPage("Page 2") ' ===> open detail page for this item
End Sub