Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SecurityToken As String
Private WV_Error As WebView
Private PNL_Main As Panel
Private PNL_Footer As Panel
Private PNL_Header As Panel
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
If SecurityToken.Length = 0 Then
Wait For(GetSecurityToken) Complete (Result As Boolean)
Wait For(Login(SecurityToken)) Complete (Result As Boolean)
Else
Wait For(Login(SecurityToken)) Complete (Result As Boolean)
If Result = True Then
Root.LoadLayout("MainPage")
Private Job As HttpJob
Job.Initialize("", Me)
Job.GetRequest.SetContentType("application/json")
Job.Download("https://music-api.amazon.com/search/?keywords=hello")
Wait For (Job) JobDone(Job As HttpJob)
Else
ToastMessageShow("Fehler beim Login", True)
End If
End If
End Sub
Private Sub JobDone(Job As HttpJob)
Dim Response As String
If Job.Success Then
Response = Job.GetString
Else
Response = Job.ErrorMessage
End If
Job.Release
If WV_Error.IsInitialized Then
WV_Error.RemoveView
Else
WV_Error.Initialize("")
Root.AddView(WV_Error, 0, 0, Root.Width, Root.Height)
End If
WV_Error.LoadHtml(Response)
End Sub
Private Sub GetSecurityToken As ResumableSub
End Sub
Private Sub Login(SecToken As String) As ResumableSub
End Sub