Sub Globals
Type ListViewData (FirstRow As String, SecondRow As String, ANum As String, Photo As Bitmap)
'...
Dim abmpurl As String
Dim abmp As Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
HttpUtils.CallbackActivity = "actPets" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"'"GetPageFromPetango"
HttpUtils.CallbackUrlDoneSub = "URLDone"
'...
HttpUtils.Download("GetPageFromPetango", Main.AnimalURL)
End Sub
Sub JobDone (Job As String)
Select Job
Case "GetPageFromPetango"
ParsePetangoPage
Case "GetAnimalPhoto"
If HttpUtils.IsSuccess(abmpurl) Then
abmp = HttpUtils.GetBitmap(abmpurl)
End If
End Select
HttpUtils.Complete = False
End Sub
Sub ParsePetangoPage
'declare some variables
'...
Dim txtrdr As TextReader
txtrdr.Initialize(HttpUtils.GetInputStream(Main.AnimalURL))
Dim line As String
line = txtrdr.ReadLine
Do While line <> Null
Dim lvd As ListViewData
lvd.Initialize
Dim b As Bitmap
'Animal Photo
If line.Contains("img class=") Then
line = line.SubString(line.IndexOf("w"))
line = "<a href=" & QUOTE & "http://www.petango.com/webservices/adoptablesearch/" & line
line = line.SubString2(line.IndexOf("src="), line.IndexOf("alt="))
line = line.SubString(line.IndexOf(QUOTE & "h"))
line = line.SubString2(line.IndexOf("http"),line.Length-1)
line = line.Replace(QUOTE, "")
abmpurl = line
HttpUtils.Download("GetAnimalPhoto", abmpurl)
End If
'Animal Name
If line.Contains("list-animal-name") Then
line = line.SubString(line.IndexOf("w"))
line = "<a href=" & QUOTE & "http://www.petango.com/webservices/adoptablesearch/" & line
AName = line
jName = AName.SubString2(AName.IndexOf(">")+1, AName.IndexOf("</"))
End If
'Animal ID
If line.Contains("list-animal-id") Then
ANumber = line
ANumber = ANumber.SubString2(ANumber.IndexOf(">")+1, ANumber.IndexOf("</"))
End If
'Animal Sex
If line.Contains("list-animal-sexSN") Then
ASex = line
ASex = ASex.SubString2(ASex.IndexOf(">")+1, ASex.IndexOf("</"))
End If
'Animal Age
If line.Contains("list-animal-age") Then
AAge = line
AAge = AAge.SubString2(AAge.IndexOf(">")+1, AAge.IndexOf("</"))
End If
'Animal Breed
If line.Contains("list-animal-breed") Then
ABreed = line
ABreed = ABreed.SubString2(ABreed.IndexOf(">")+1, ABreed.IndexOf("</"))
End If
'End of this animal's table row
If line = "</td>" Then
lvd.FirstRow = jName
lvd.SecondRow = AAge & " " & ASex
lvd.ANum = ANumber
lvd.Photo = abmp
lvPets.AddTwoLinesAndBitmap2(lvd.FirstRow, lvd.SecondRow, lvd.Photo, lvd)
Else
'Don't do anything
End If
line = txtrdr.ReadLine
Loop
txtrdr.Close
End Sub