B4J Question Questions on CLV Visible Range in SMM Example2

CR95

Active Member
Licensed User
On a Windows system, I installed SMM Example2 from :
https://www.b4x.com/android/forum/t...rk-for-images-videos-and-more.134716/#content

In the B4J version, I added the following line in the sub CustomListView1_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int) :
B4X:
Log("i= " & i & " FirstIndex= " & FirstIndex & " LastIndex= " & LastIndex)

After execution of the program, I find in the Log :
B4X:
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
i= 0 FirstIndex= 0 LastIndex= 2
i= 1 FirstIndex= 0 LastIndex= 2
i= 2 FirstIndex= 0 LastIndex= 2
i= 3 FirstIndex= 0 LastIndex= 2
i= 4 FirstIndex= 0 LastIndex= 2
i= 5 FirstIndex= 0 LastIndex= 2
which means that the program loaded 6 rows of photos (although the visible part of the CLV counts only 3 rows).

From my understanding, something is strange that the program loads 6 rows instead of 3.
Is there a explanation ?

In a second trial, I remove (always in the same Sub) the line :
B4X:
For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)

And I replace it by :
B4X:
Dim i as Int
For i = FirstIndex to LastIndex

Execution should be the same ! In this case, i find in the Log :
B4X:
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
i= 0 FirstIndex= 0 LastIndex= 2
i= 1 FirstIndex= 0 LastIndex= 2
i= 2 FirstIndex= 0 LastIndex= 2

Number of lines is "coherent" BUT nothing appears in the Form.
How to explain that ?

Last question :
In the line
B4X:
Dim item As CLVItem = CustomListView1.GetRawListItem(i)
when I move the mouse on "GetRawListItem", it is noted
"Returns the CLVItem. Should not be used in most cases"
What are the cases when this instruction should not be used ?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
And I replace it by :
This will not work. You need to go over the source code before making such changes.

Correct answer:
It loads 3 more items to allow smooth scrolling. You don't need to be bothered about it.

Less correct answer:
There is an ExtraItems field that you can modify to change this behavior.
 
Upvote 0

CR95

Active Member
Licensed User
Thanks Erel
This will not work. You need to go over the source code before making such changes.
"Je reste sur ma faim" -> French expression which can be translated by "I am always hungry"
If you have 5 minutes, please could you explain why
B4X:
For i = FirstIndex to LastIndex
and
B4X:
For each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
have different behavior ?
I put tracing in the sub and the loop process is the same in both cases.
How to explain that - with the "For" instruction - nothing appears in the Form ?
In fact, the true issue for me is to understand why the PLCV (or the MediaManager ?) does not show the loaded images
 
Upvote 0

CR95

Active Member
Licensed User
Thanks but I don't have the level to understand the SimpleMediaManager library.
Anyway, I found in the source that there was a conditional symbol = SMM_DEBUG.
I made 2 trials with SMM_DEBUG (one with "for each i...." and one with "for i =....") and in both cases, the logs are strictly identical.
After looking the tracing, I don't think that SimpleMediaManager is responsible of the "empty" form with "for i = ....".
I rather think that PCLV is not "refreshed" !
 
Upvote 0
Top