B4A Library [B4X] PreoptimizedCLV - Lazy loading extension for xCustomListView

monki

Active Member
Licensed User
Longtime User
hello erel,
the same error message as with Klaus. I inserted 80000 entries for the test, but the list cannot be scrolled to the end, if you pull the fast scroller down, the entries are shown to the end, but when you release the scroller, the list cannot be scrolled to the end Problem occurs from about 90000 entries.

monki
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please upload the project.
 

monki

Active Member
Licensed User
Longtime User
Hi there,
I only changed the creation of the entries from the sample code as follows for the test




B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    PCLV.Initialize(Me, "PCLV", CustomListView1)
    Dim words As List = File.ReadList(File.DirAssets, "english.txt")

'    For Each word As String In words
    For t= 1 To 90000
   
'  
        PCLV.AddItem(100dip, xui.Color_White, t)

    Next
    PCLV.Commit
End Sub
 

Jorge M A

Well-Known Member
Licensed User
changed the creation of the entries
I think it is not enough. The text file has only 10000 entries.
In my case, i generate other txt file with 230,000 (stressing the list), but have the same problem.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've added a note about the limit. See the first post.

There are UX limits that make lists with 50k+ items impractical anyway. I'll explain:
The fast scroller cannot have too many stop points or it will be very difficult to accurately get to the desired point.
By default the fast scroller is set to have 20 steps (stop points). With 50k items the number of items between each step will be about 2,500 items. No user will ever want to scroll this number of items to get to a specific item.
 
Last edited:

Jorge M A

Well-Known Member
Licensed User
Just for the record and since PreoptimizedCLV is a cross platform, I transferred the sample code to B4J, and it worked without any problem with 230,000 items.
Many Thanks!
 

seyed_27

Member
error in PCLV_Example2.zip
 

MrKim

Well-Known Member
Licensed User
Longtime User
Erel, I love it! I was going to give up on BCTextEngine as just too slow for my needs but this solved it but with a couple of problems.

First, the (Fast?)scrolling scroll bar doesn't work. It is odd dragging it doesn't work at all but I can scroll with the mouse and when I do the scrollbar "Dot" "Tracks" it perfectly. For my needs I would prefer to have the option of using the regular scrollbar My list isn't that large (0-250) it just gets updated frequently. I have two other customlistviews on the form and I want them to all look the same. Allos, the scrollbar (Line Really) sticks out into the list.


Sigh, also Using the BBLabel I had finally figured out how to store and retrieve my map file in Both the on click event and when dragging and dropping. After switching the code to this I can't get it to work again.

Here is my code snippets:
B4X:
        Do While Crsr.NextRow = True
                Dim M As Map
                M.Initialize
                M.Put("Os_JobNum", Crsr.GetString("Os_JobNum"))
                M.Put("Os_ReleaseNum", Crsr.GetString("Os_ReleaseNum"))
                M.Put("Os_SeqNum", Crsr.GetString("Os_SeqNum"))
                M.Put("Os_WCCode", Crsr.GetString("Os_WCCode"))
                M.Put("Os_ID", Crsr.GetInt("Os_ID"))
                M.Put("Scheduled", False)
                PCLV.AddItem(50, xui.Color_ARGB(255, 186, 204, 210), M)
                zx=zx+1
                If zx = 12 Then
                Sleep(0)  'forces view of what is loaded so far
            End If
            'Sleep(1)
        Loop
        PCLV.Commit
        Crsr.Close


Sub PCLV_HintRequested (Index As Int) As Object
    Dim word As Map = UnSchedOpsList.GetValue(Index)
    Return word
End Sub


Sub UnSchedOpsList_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    'Log("Now")
    For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
        Dim item As CLVItem = UnSchedOpsList.GetRawListItem(i)
        'Create the layout for item i and add it to item.Panel.
        Dim M As Map = item.Value
        Dim P As B4XView = xui.CreatePanel("UnschOPs")', TE As BCTextEngine
        Dim DT As String = M.Get("Os_StartbyDate")
        If DADMod.Isnull(DT) Then DT = "N/A" Else DT = DT.SubString2(0, 5)
        P.Tag = M
        P.LoadLayout("BBLabel")
        M.Put("BBLbl", P.GetView(0).Tag)
        TextEngine.Initialize(P)
        UnschOPsBB.Text = ScheduleMod.CheckForLate(M.Get("Os_StartbyDate"), 3) & $"  [Color=blue][b][u]"$ & M.Get("Os_JobNum") & $"[/u][/b][/Color] / [Color=black][b][u]"$ & M.Get("Os_ReleaseNum") & $"[/u][/b][/Color] Op [Color=#0000ff][b][u]"$ & M.Get("Os_SeqNum") & $"[/u][/b][/Color]"$
        'item.Color = xui.Color_ARGB(255, 126, 180, 250)
        item.Panel.AddView(P, 0, 0, 300, 50)
        DandD1.MakeDragSource(item.Panel, "DandD1")
        UnschOPsBB.Tag = M.Get("Os_ID")
    Next
End Sub
For one thing, since we are no longer using CLV.Add but PCLV.AddItem I am no longer sure exactly what is returned inSub CLV_ItemClick. I used to store the Map in My Panel.Tag (P) and and Make P the Value returned. That no longer works. I have now made item.Panel my drag source, which does start the drag event, but again, I cannotfigure out how to retrieve my map from the tag.

Thanks for your help.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…