Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private multipleMsgs As Map 'tracks msgs
End Sub
Public Sub Initialize
multipleMsgs.Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
TestWaitingMethod
End Sub
Private Sub TestWaitingMethod
'....Some code
ShowMessage1
'....Some code
ShowMessage2
'Test if any messages are waiting - test method
For i = 0 To 10
testForWaitingMessages
Sleep(1000)
Next
End Sub
Private Sub testForWaitingMessages
For Each kw As String In multipleMsgs.Keys
Dim msg As Object = multipleMsgs.Get(kw)
Dim jo As JavaObject = msg
Dim result As String = jo.RunMethod("isShowing", Null)
Log(kw & TAB & result)
Next
Log(TAB)
'Log output
'Delete file? true
'Finished task? true
' After closing msg2
'Delete file? true
'Finished task? false
' After closing msg1
'Delete file? false
'Finished task? false
End Sub
Private Sub ShowMessage1
Dim sf As Object = xui.Msgbox2Async("Delete file?", "Title", "Yes", "Cancel", "No", Null)
multipleMsgs.Put("Delete file?", sf)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
Log("Deleted!!!")
End If
End Sub
Private Sub ShowMessage2
Dim sf As Object = xui.Msgbox2Async("Finished task?", "Title", "Yes", "Cancel", "No", Null)
multipleMsgs.Put("Finished task?", sf)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
Log("Finished!!!")
End If
End Sub