Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If
Activity.LoadLayout("1")
ler_dados_agenda
Sub ler_dados_agenda
ProgressDialogShow("Lendo_agenda")
ExecuteRemoteQuery("SELECT id_agenda,data,hora_inicio,hora_fim,id_aluno,id_instrutor,matricula,id_status FROM agenda ORDER BY id_agenda", ler_agenda)
End Sub
Sub ler_dados_aluno (aluno As String)
id=aluno
ExecuteRemoteQuery("SELECT nome,apelido FROM alunos WHERE id_aluno='" & id &"'", ler_aluno)
ToastMessageShow (id, False) - ALL ID VALUES APPEAR . NO PROBLEM HERE
End Sub
Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
Dim req As HttpRequest
req.InitializePost2("bla bla bla..my server and service, Query.GetBytes("UTF8"))
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Erro: " & Reason & ", codigo: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
ProgressDialogHide
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim res As String
res = Response.GetString("UTF8")
Log("resposta do servidor: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select TaskId
Case ler_agenda
Dim agenda As List
agenda = parser.NextArray 'devolve em maps
For i = 0 To agenda.Size - 1
Dim m As Map
m = agenda.Get(i)
Dim tl As linhas_agenda
tl.campo1 = m.Get("id_agenda")
tl.campo2 = m.Get("data")
tl.campo3 = m.Get("hora_inicio")
tl.campo4 = m.Get("hora_fim")
tl.campo5 = m.Get("id_aluno")
tl.campo6 = m.Get("id_instrutor")
tl.campo7 = m.Get("matricula")
tl.campo8 = m.Get("id_status")
ler_dados_aluno (tl.campo5)
ToastMessageShow (id, False)
'ListView1.AddSingleLine(tl.campo1&" "& tl.campo2&" "&tl.campo3&" "&tl.campo4&" "&tl.campo5&" "&tl.campo6&" "&tl.campo7&" "&tl.campo8)
Next
ProgressDialogHide
Case ler_aluno
Dim alunos As List
alunos = parser.NextArray 'devolve em maps
For j = 0 To alunos.Size - 1
Dim n As Map
n = alunos.Get(j)
la.nome = n.Get("nome")
la.apelido = n.Get("apelido")
nome2=n.Get("nome")
apelido2=n.Get("apelido")
Next
End Select
Response.Release
End Sub