I tried to download more then 500 images and show it in a CustomListView. The urls of the images is in an database.
I used the code "DownloadImage" of this thread
https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/#content
The images is are display correctly, but the images of the first records take a long time to display, before the others.
I want to the images of the first record is display first and I put a "If mod 10 = 0 then Sleep(100)" in the code, to paused the display every 10 records:
This worked (the first images is display), but when I try to close the activity don't works. The activity is restarted and I get the this message in the log:
How I can fix this problem and show the images of the first records in sequence?
Thanks in advance for any tip.
I used the code "DownloadImage" of this thread
https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/#content
B4X:
Sub CreateCustomList
dbCursor.Position = 0
For i = 0 To dbCursor.RowCount - 1
dbCursor.Position = i
clv.Add(CreatePanel(i), 70dip, i)
Next
End Sub
Sub CreatePanel(i As Int) As Panel
Dim p As Panel
p.Initialize("panel")
Activity.addview(p,0,0,100%x,100%y)
p.LoadLayout("cellprofile")
p.RemoveView
lbName.Text = dbCursor.GetString("name")
DownloadImage(dbCursor.GetString("image"), ivPhoto)
Return p
End Sub
I want to the images of the first record is display first and I put a "If mod 10 = 0 then Sleep(100)" in the code, to paused the display every 10 records:
B4X:
Sub CreateCustomList
dbCursor.Position = 0
For i = 0 To dbCursor.RowCount - 1
dbCursor.Position = i
clv.Add(CreatePanel(i), 70dip, i)
If i Mod 10 = 0 Then Sleep(100)
Next
End Sub
This worked (the first images is display), but when I try to close the activity don't works. The activity is restarted and I get the this message in the log:
B4X:
Sleep not resumed (context destroyed): com.myapp.listprofiles$ResumableSub_CreateCustomList
Thanks in advance for any tip.