Android Question Lock xCLV

KZero

Active Member
Licensed User
Longtime User
Hi,

is it possible to make xCLV draw items offscreen and disable visibleRangeChange event while adding many items?

such as BeginUpdate , EndUpdate or Lock and Unlock in other languages
 

DonManfred

Expert
Licensed User
Longtime User
You know when your app is in the Phase of "BeginUpdate" or "EndUpdate".
You should ignore this Event after BeginUpdate and react on the Event again after EndUpdate.
 
Upvote 0

KZero

Active Member
Licensed User
Longtime User
i tried to make that

B4X:
LockCLV=True
Add50ItemToList
LockCLV=False

Sub CLV_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
if LockCLV=True then return

but CLV_VisibleRangeChanged event fired after I finish adding items

it fires many times for each visible item

CLV_VisibleRangeChanged(0,1)
CLV_VisibleRangeChanged(0,2)
CLV_VisibleRangeChanged(0,3)
CLV_VisibleRangeChanged(0,4)
........
CLV_VisibleRangeChanged(40,50)

the following code is working but I'm looking for the best approach
B4X:
LockCLV=True
Add50ItemToList
sleep(50)
LockCLV=False

also if it was possible to disable xCLV drawing for each item and draw once after adding all items i think it will be much faster
 
Upvote 0

KZero

Active Member
Licensed User
Longtime User
I already implemented lazy loading,

the problem is when I add many items at once the CLV_VisibleRangeChanged event fired many times (it should only fire one time when adding items complete)

i fixed it

this code removed the unnecessary CLV_VisibleRangeChanged events which happen while items being added
B4X:
CLV.DisableVisibleRange=True
AddItemsToList
CLV.DisableVisibleRange=False
CLV.Refresh

customlistview.bas
B4X:
Private Sub UpdateVisibleRange
    If DisableVisibleRange=True Then Return '<<<<<<<<<<<<<<<<<<<
    If MonitorVisibleRange = False Or getSize = 0 Then Return
    Dim first As Int = getFirstVisibleIndex
    Dim last As Int = getLastVisibleIndex
    If first <> mFirstVisibleIndex Or last <> mLastVisibleIndex Then
        mFirstVisibleIndex = first
        mLastVisibleIndex = last
        CallSubDelayed3(CallBack, EventName & "_VisibleRangeChanged", mFirstVisibleIndex, mLastVisibleIndex)
    End If
End Sub
 
Upvote 0
Top