Hi, I'm currently working on this event https://www.b4x.com/android/forum/threads/visiblerangechanged-problems-with-imagedownloader.94620/, Erel helped me solve a problem but two things are happening to me
1. HttpJob takes a while to complete if the user leaves the activity, when HttpJob completes this it returns me to the original activity
2. I get an error:
Error occurred on line: 147 (CustomListView)
java.lang.IndexOutOfBoundsException: Invalid index 15, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
my solution
but sometimes the application stops with this error
when user leaves the view quickly this calls the event Activity_KeyPress how to control from here?
my code:
1. HttpJob takes a while to complete if the user leaves the activity, when HttpJob completes this it returns me to the original activity
2. I get an error:
Error occurred on line: 147 (CustomListView)
java.lang.IndexOutOfBoundsException: Invalid index 15, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
my solution
B4X:
StopService(HttpUtils2Service)
B4X:
line 633: topService(HttpUtils2Service)
Error ocurred on line:633(productos)
java.lang.ClassCastException: anywheresoftware.b4a.samples.httputils2.httpjob cannot be cast to android.content.Intent
when user leaves the view quickly this calls the event Activity_KeyPress how to control from here?
my code:
B4X:
Sub CLV_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim ExtraSize As Int = 20
For i = 0 To CLV.Size - 1
Dim p As B4XView = CLV.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
'visible+
Try
If p.NumberOfViews = 0 Then
Dim cd As CardData = CLV.GetValue(i)
p.LoadLayout("CellItem2")
lblnombre.Text = cd.nombre
lbldescripcion.Text = cd.descripcion
lblprecio.Text = cd.precio
Dim j As HttpJob
Dim iv As ImageView = img2 'must be a local variable
j.Initialize("", Me)
j.Download("http://solodomis.com/solodomis/aliados/"&id_emp&"/productos/"&cd.id&".png")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
iv.Bitmap = j.GetBitmapResize(15%x,15%y,True)
End If
j.Release
End If
End If
Catch
Log(LastException)
End Try
Else
'Not visible
' If p.NumberOfViews > 0 Then
' p.RemoveAllViews
' End If
End If
Next
End Sub