Sub Activity_Create(FirstTime As Boolean)
ServerIP="localhost:85" ' The ip address where you Xampp installation runs
End Sub
Sub InsertNewPersonButton_Click
If NameET.Text.Length<2 Then
Msgbox("Name is missing or to short", "Name")
Return
End If
If AgeET.Text = "" Then
Msgbox("Age is missing", "Age")
Return
End If
Dim InsertNewPerson As HttpJob
InsertNewPerson.Initialize("InsertNewP", Me)
InsertNewPerson.download2("http://" & ServerIP & "/persons/persons.php", Array As String ("action", "InsertNewPerson", "name", NameET.Text, "age", AgeET.Text))
End Sub
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Back from Job:" & Job.JobName )
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case "GetP"
Dim ListOfPersons As List
Dim PersonName As String
Dim PersonAge As Int
ListOfPersons = parser.NextArray 'returns a list with maps
PersonsListview.Clear
If ListOfPersons.Size=0 Then
PersonsListview.AddSingleLine ("No persons found...")
Else
For i = 0 To ListOfPersons.Size - 1
Dim Person As Map
Person = ListOfPersons.Get(i)
PersonName = Person.Get("name")
PersonAge = Person.Get("age")
PersonsListview.AddSingleLine (PersonName & ", " & PersonAge)
Next
End If
Case "CountP"
PersonsListview.AddSingleLine ("Persons in table: " & parser.NextValue)
Case "InsertNewP"
'Do nothing
End Select
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub