Android Question Never get JobDone status in HttpJob

nickysuwandi

Member
Licensed User
Longtime User
i try to download list image in web server folder and display in image slider.

1. download list of web server image file

B4X:
Wait For (CallSub2(Starter , "FindImages",  Starter.serverAddress & "/promo/index.php")) Complete (success As Boolean)

2. i am put FindImages sub in starter

B4X:
Public Sub FindImages (root As String) As ResumableSub
    Dim j As HttpJob
    j.Initialize("findimage", Me)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Dim str As String = j.GetString
        Log(j.GetString)
        Dim rb As RegexBuilder
        rb.Initialize
        'rb.Initialize.AppendEscaped("""").Append(rb.CharAny).AppendAtLeastOne.AppendEscaped(".jpg""")
        rb.Initialize.AppendEscaped("a href=""").Append(rb.CharAny).AppendAtLeastOne.AppendEscaped(".jpg""")
        Dim m As Matcher = Regex.Matcher2(rb.Pattern, Regex.MULTILINE , str)
        Do While m.Find
            'Dim link As String = m.Group(0).Replace("""","")
            Dim link As String = m.Group(0).Replace("a href=","").Replace("""","")
            If link.StartsWith("http") = False Then
                If link.StartsWith("/") = False Then link = "/" & link
                link = root & link
            End If
            Log(link)
            MainMenu.urlspromo.Add(link)
        Loop
    End If
    j.Release
    Return j.Success
End Sub

3. my index.php to list the image file in server folder

B4X:
<?PHP
    $all_files = glob("*.*");
    for ($i=0; $i<count($all_files); $i++)
    {
      $image_name = $all_files[$i];
      $supported_format = array('gif','jpg','jpeg','png');
      $ext = strtolower(pathinfo($image_name, PATHINFO_EXTENSION));
      if (in_array($ext, $supported_format))
          {
            echo '<img src="'.$image_name .'" alt="'.$image_name.'" />'."<br /><br />";
          } else {
              continue;
          }
    }
?>

I never get JobDone status from this code, please someone help me.

Thanks

Nicky
 

DonManfred

Expert
Licensed User
Longtime User
Dim j As HttpJob
j.Initialize("findimage", Me)
Wait For (j) JobDone(j As HttpJob)
You job does; NOTHING
Start the job if you want to get a result. Poststring, Download....
 
Last edited:
Upvote 0
Top