#Region Project Attributes
#ApplicationLabel: Nortech API Test
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: True
#IncludeTitle: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Label1 As Label
Private Button1 As Button
Private ListView1 As ListView
Private Label2 As Label
Private apptDetail As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("API_Test")
End Sub
Sub Activity_Resume
refresh
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
private Sub refresh()
ListView1.Visible = True
apptDetail.Visible = False
ListView1.Clear
Label1.Text = "Fetching data"
Dim Job As HttpJob
Job.Initialize("api", Me) ' Init HttpJob
Job.PostString("https://nortechcomputers.co.uk/nortech/v1.0/api/index.php?secret=123456","") ' POST to url
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
Dim res As String
Dim myAppointments As Appointments
Dim myAppointment As Appointment
res = Job.GetString ' Result from php store to result
Log("Response from server: " & res) ' Show all of result from server to log
myAppointment.Initialize
myAppointments.Initialize
myAppointments.parseJSON(res)
For i = 0 To myAppointments.appointmentList.Size - 1
'ListView1.AddSingleLine(myAppointments.appointmentList.get(i))
myAppointment = myAppointments.appointmentList.Get(i)
Log ("Reading myAppointment.serv_id = " & myAppointment.serv_id & " as appointment " & i)
Next
Else
Log(Job.ErrorMessage) ' Error detect
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub Button1_Click
refresh
End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
apptDetail.Visible = True
ListView1.Visible = False
apptDetail.Text = "Appointment Position = " & Position & " Value = " & Value
End Sub