Android Question Cascade httpJob

Prosg

Active Member
Licensed User
Longtime User
Hello,

I have a customlistView who is populate with this job.
But i need to have a select for each row to know their rating (in another table and i can't do one Sql Select for both like INNERJOIN...

I use another job in this job ?

Regards

B4X:
Sub JobDone (Job As HttpJob)
    ProgressDialogHide
    If Job.Success Then
    Dim res As String, action As String
        res = Job.GetString
        'Log("Back from Job:" & Job.JobName  & ", Success = " & Job.Success)
        'Log("Response from server: " & res)  
   
        Dim parser As JSONParser
        parser.Initialize(res)
           
        Select Job.JobName
            Case "httpSearchResult"
                Dim infos As List
                infos = parser.NextArray 'returns a list with maps
                For i = 0 To infos.Size - 1
                    Dim m As Map
                    m = infos.Get(i)
               
                    Dim tempUser As Person
                    tempUser.prenom = m.Get("Prenom")
                    tempUser.nom =  m.Get("Nom")
                    tempUser.id =  m.Get("id")
                    tempUser.poste = m.Get("Metier")
                    tempUser.poste = tempUser.poste.Replace("\'", "'")
                    tempUser.competence1 = m.Get("Competence1")
                    tempUser.competence1 = tempUser.competence1.Replace("\'", "'")
                    tempUser.competence2 = m.Get("Competence2")
                    tempUser.competence2 = tempUser.competence2.Replace("\'", "'")
                    tempUser.competence3 = m.Get("Competence3")
                    tempUser.competence3 = tempUser.competence3.Replace("\'", "'")
                    tempUser.statutDipo = m.Get("Disponible")
                    tempUser.typeDeCompte = m.Get("TypeDeCompte")
                    tempUser.telMobile = m.Get("TelMobile")
                    tempUser.avatarNom = m.Get("Avatar")
                    If m.Get("Lat") <> Null Then
                        If m.Get("Lat") <> "" Then tempUser.lat = m.Get("Lat")
                    End If
                    If m.Get("Lng") <> Null Then
                        If m.Get("Lng") <> "" Then tempUser.lng = m.Get("Lng")
                    End If   
                    custlist.Add(addLabel (i, 100%x -20dip, 200dip, tempUser),200dip, "secteurActivite", False)

'****** I NEED TO DO A SELECT FOR EACH id TO KNOW RATINGS ***************
                Next
       
   
        End Select
    Else
        'Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub

here is the other table

 

Prosg

Active Member
Licensed User
Longtime User
I did the Cascade on a job all works fine execpt if the user click quickly to the button to back (real : activity finish)

here the code to back

B4X:
Sub ActionBar_NavigationItemClick
    CallSubDelayed(Main_Menu, "afterSearch")
    Activity.finish
   
End Sub

sometimes i have this bug

I think it's because it doesn't find the custlistView cause the activity is finish

B4X:
customlistview_getpanel (B4A line: 78)
p = panels.Get(Index) 'this is the parent panel
java.lang.IndexOutOfBoundsException: Invalid index 8, size is 0
    at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
    at java.util.ArrayList.get(ArrayList.java:308)
    at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
    at com.wanteeds.prosg.customlistview._getpanel(customlistview.java:335)
    at com.wanteeds.prosg.searchresult._jobdone(searchresult.java:1370)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:198)
    at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:157)
    at anywheresoftware.b4a.debug.Debug.wait(Debug.java:224)
    at anywheresoftware.b4a.debug.Debug.reachBP(Debug.java:365)
    at anywheresoftware.b4a.debug.Debug.ErrorCaught(Debug.java:156)
    at com.wanteeds.prosg.customlistview._getpanel(customlistview.java:344)
    at com.wanteeds.prosg.searchresult._jobdone(searchresult.java:1370)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.keywords.Common$5$1.run(Common.java:981)

how to fix that?
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
What do you expect? The OS can't do any magic It's up to you (your app) to handle the stuff.

In every case you will get a reaction (event). Job.Done will called anyway (even if it get's a timeout). Here you must handle it. So it's how it works.
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
ok i think it's not possible to check the job status directly in ActionBar_NavigationItemClic

i must have a global value
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
i test with a global value... but it doesn't work... i think i need to know how mutch task is waiting or something like this
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
ok i've got it with a part of code i find by erel

in global
B4X:
    Dim jobList As List
    Dim okClick As Boolean = False

Initialisze in activity create

B4X:
jobList.Initialize

Each times i have a job in my activity i add to joblist

B4X:
jobList.Add("job")
    Dim httpSearchResult As HttpJob

Just before the job.success i add

B4X:
Sub JobDone (Job As HttpJob)
 
     If jobList.Size > 0 Then
        jobList.RemoveAt(0)
    End If

    If Job.Success Then



in Job.success just before else

B4X:
            If jobList.Size > 0 Then
            Log( "Executing Job "&jobList.IndexOf(0))
         
        Else
            Log( "All Jobs are done")
              okClick = True
       
        End If

      
    Else
        'Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release 
End Sub

And where i close activity i do this

B4X:
Sub ActionBar_NavigationItemClick
  
     If okClick = True Then
       CallSubDelayed(Main_Menu, "afterSearch")
       Activity.finish
     End If
End Sub

Maybe it could help someone one day
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…