Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Drawer.Initialize(Me, "Drawer", Root, 400dip)
Drawer.LeftPanel.LoadLayout("LeftMenu")
LoadSlideMenu(1)
End Sub
Sub CreateRequest As DBRequestManager
Dim req As DBRequestManager
req.Initialize(Me, Main.rdcLink)
Return req
End Sub
Sub CreateCommand (Name As String, Parameters() As Object) As DBCommand
Dim command As DBCommand
command.Initialize
command.Name = Name
If Parameters <> Null Then command.Parameters = Parameters
Return command
End Sub
Private Sub CreateMenu(MenuText As String) As B4XView
Dim Height As Int = 60dip
Dim Width As Int = clvLeftMenu.AsView.Width
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("MenuItem")
lblMenu.Text = MenuText
Return p
End Sub
Sub LoadSlideMenu (isLogin As Int)
Dim req As DBRequestManager = CreateRequest
Dim com As DBCommand = CreateCommand("getMenus", Array As Object(isLogin))
Wait For (req.ExecuteQuery(com, 0, Null)) JobDone (job As HttpJob)
If job.Success Then
req.HandleJobAsync(job, "req")
Wait For (req) req_Result (res As DBResult)
'req.PrintTable(res)
clvLeftMenu.Clear
For Each row() As Object In res.Rows
clvLeftMenu.Add(CreateMenu(row(0)), row(0))
Next
Else
xui.MsgboxAsync(job.ErrorMessage, "Error")
End If
job.Release
Log("Left Menu populated")
End Sub
Private Sub clvLeftMenu_ItemClick (Index As Int, Value As Object)
Log(Value)
End Sub