'Activity module
Sub Process_Globals
Dim Parser As SaxParser
Dim hc As HttpClient
Dim req As HttpRequest
End Sub
Sub Globals
Dim RSS As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
Parser.Initialize
RSS.Width = 100%x
RSS.Height = 100%y
hc.Initialize("hc")
req.InitializeGet("http://www.opendata.provincia.roma.it/storage/f/2012-10-09T145911/CENTRIASCOLTOFEMMINILEPROVINCIADIROMA.xml")
hc.Execute(req,1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause(UserClosed As Boolean)
End Sub
Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("GetRSS",File.OpenOutput(File.DirDefaultExternal,"RSS.xml", False), True, TaskId)
End Sub
Sub hc_ResponseError(Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
If Response <> Null Then
Msgbox("Error: " & Response.GetString("UTF8"), "Connection Error")
Response.Release
End If
End Sub
Sub GetRSS_StreamFinish(Success As Boolean, TaskId As Int)
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
Dim In As InputStream
In = File.OpenInput(File.DirDefaultExternal, "RSS.xml")
Parser.Parse(In, "Parser")
In.Close
End Sub
Sub Parser_StartElement(Uri As String, Name As String, Attributes As Attributes)
If Name = "Denominazione" Then
RSS.TwoLinesLayout.ItemHeight = 140dip
RSS.TwoLinesLayout.SecondLabel.Height = 70dip
Dim s As String
For i = 0 To Attributes.Size
s = s & " " & Attributes.GetValue2("", "Denominazione")
Next
RSS.AddTwoLines(s, Attributes.GetValue(1) )
End If
End Sub
Sub Parser_EndElement(Uri As String, Name As String, Text As StringBuilder)
End Sub