#Region Activity Attributes
#FullScreen: False
#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.
Dim ObjectClass As String
Dim LV As ListView
Private Toolbar As Panel
Private Caption 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("ListHandlerLayout")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub BuildList(URL As String, OClass As String)
'ToastMessageShow(URL & " " & ObjectClass, True)
Dim Job As HttpJob
LV.Clear
ObjectClass = OClass
Job.Initialize("ListJob", Me)
Job.Username = Main.manager.GetString("Login")
Job.Password = Main.manager.GetString("Password")
Job.Download(URL)
Wait For (Job) JobDone(Job As HttpJob)
If Job.Success Then
FillListView(Job.GetString)
Else
Log("Job Failed: " & Job.ErrorMessage)
ToastMessageShow("Job Failed: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub LV_ItemClick (Position As Int, Value As Object)
ToastMessageShow(Value, True)
End Sub
Sub FillListView(Data As String)
Dim JP As JSONParser
JP.Initialize(Data)
Caption.Text = ObjectClass
Dim root As List = JP.NextArray
For Each colroot As Map In root
Dim Id As String = colroot.Get("Id")
Dim Name As String = colroot.Get("Name")
LV.SingleLineLayout.Label.TextColor = Colors.Black
LV.AddSingleLine2(Name, Id)
Next
End Sub