Android Question How to Access this Function from Class Module as correctly ?

Pravee7094

Active Member
Hello all,
I have a little confusion with "Wait For" and "Job Done"

We fetch the data from internet database through API using slim framework.
Thinking of reduce the code, we just write the common used code as function in one class module(standard) and used it whatever we wants.

So, Highly we used common code for fetching data from internet database. so, we decided to write the code as function in the class module.

What we wrote in activity Module :
B4X:
Sub Get_RegStatus As ResumableSub
    Dim ll_list As List
    ll_list.Initialize
    Dim lm_map As Map
    lm_map.Initialize

    lm_map.Put("mobileregistrationpk", is_mobileregistrationpk)
    ll_list.Add(lm_map)

    Dim ls_result As String
    Dim ls_url As String = "http://IP_Address/FolderName/mobileregistration/checkRegStatus"
    EliteUtils.GetResultFromDB(ll_list, ls_url, ls_result) 'EliteUtils -> Class Module Name

    Log("Returned Reg Status : " & ls_result)

    Return False
End Sub

In Class Module (EliteUtils) :
B4X:
Public Sub GetResultFromDB(send_data As List, url As String, ls_result As String) As ResumableSub
    Dim ls_jsongenerator As JSONGenerator
    Dim ls_http As HttpJob

    ls_jsongenerator.Initialize2(send_data)
    
    Dim ls_jsonstr As String
    ls_jsonstr = ls_jsongenerator.ToString
    
    If ls_jsonstr = "" Then
        MsgboxAsync("Data is Empty", "Error")
        Return True
    End If
    
    ls_http.Initialize("j1",Me)
    ls_http.PostString(url, ls_jsonstr)
    Wait For (ls_http) JobDone(ls_http As HttpJob)

    If ls_http.Success = False Then
        MsgboxAsync("Could not connect to webserver","Error")
        Return True
    Else

    End If
                
    ls_result = ls_http.GetString
    Log("Returned Reg Status (Elite Utils) : " & ls_result)

    Return False
End Sub

Got Message In "Logs" Page :
B4X:
Object context is paused. Ignoring CallSubDelayed: JobDone

Note 1 : If we write the same code in Activity Module (same function), It works fine.
Note 2 : We can access and used other function from the same class module. (Without "Wait For" and "JobDone")

But, How to I access this function from class module as correctly?
Any suggestion?

Thanks
 
Top