Android Question ProgressDialogShow2 spinning icon not showing

Indy

Active Member
Licensed User
Longtime User
Hi

I use a ProgressDialogShow2 just before initiating a HTTP web service call and using the Wait For to pause until I get a return. However, I've noticed that I get no spinning icon on the ProgressDialogShow2 box. Would this have something to do with the Wait For?

B4X:
ProgressDialogShow2("Please wait, authenticating device..", False)

Global.FetchData(HttpConn,Me)
   
Wait For (Global.HttpJobReq) JobDone(HttpJobRes As HttpJob)
   
ProgressDialogHide

It's not a deal breaker for me, I can live with it but, I would have preferred the spinning icon to indicate to the user that something is actually happening.

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
Add a small sleep after you show the Progressdialog

B4X:
ProgressDialogShow2("Please wait, authenticating device..", False)
sleep(250)
[...]
 
Upvote 0

Indy

Active Member
Licensed User
Longtime User
Add a small sleep after you show the Progressdialog

B4X:
ProgressDialogShow2("Please wait, authenticating device..", False)
sleep(250)
[...]

Unfortunately, this hasn't worked. I'm using the AppCompat library in my project to give older devices the look and feel of Material design. Do you think it might be that affecting things?
 
Upvote 0

Indy

Active Member
Licensed User
Longtime User
What are you doing in Global.FetchData ?

I'm basically just doing a typical HTTP web services call using OKHttp. Instead of repeating the same few lines, I've just put things in a more reusable function called FetchData in a Global module.
 
Upvote 0

Indy

Active Member
Licensed User
Longtime User
The thing is everything works fine. The Wait For logic works perfectly so I know there can't be anything wrong with my technique of using a function to process http calls. I use the same function all over my project and it's perfect. It's almost as if the Wait For isn't processing any UI updates.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It's almost as if the Wait For isn't processing any UI updates.
No. The problem is in your FetchData code. I cannot say anything else without seeing the code.

It is almost always a mistake not to use OkHttpUtils2. You can make any request you like with it and it will not freeze the UI.
 
Upvote 0

Indy

Active Member
Licensed User
Longtime User
Here's the function code;

B4X:
Sub FetchData(HttpConn As WSConn,M_e As Object)

   Dim strFilterXML As String = "<soap:Body><" & HttpConn.WCFFuncName & " xmlns=""" & HttpConn.WCFServerIP & "/""><" & HttpConn.WCFFuncParamName & ">" & Main.DID & "</" & HttpConn.WCFFuncParamName & "></" & HttpConn.WCFFuncName & "></soap:Body>"

   HttpJobReq.Initialize("HttpJobReq", M_e)

   If HttpConn.WCFFuncParamName <> "" Then
       HttpJobReq.PostString( HttpConn.WCFServerIP & "/" & HttpConn.WCFProjectName & "/" & HttpConn.WCFInterfaceName, XML.Replace("<soap:Body />", strFilterXML))
   Else
       HttpJobReq.PostString( HttpConn.WCFServerIP & "/" & HttpConn.WCFProjectName & "/" & HttpConn.WCFInterfaceName, XML)
   End If

   HttpJobReq.GetRequest.SetHeader("SOAPAction", HttpConn.WCFServerIP & "/" & HttpConn.WCFFuncName)
   HttpJobReq.GetRequest.Timeout = 180000 'milliseconds timeout
   HttpJobReq.GetRequest.SetContentType("text/xml; charset=utf-8")

End Sub

Sorry it looks somewhat messy. I'm using lots of variables to build the string but, suffice to say this does all work ;)
 
Upvote 0

Indy

Active Member
Licensed User
Longtime User
How long does it take JobDone to be raised? Have you tested it in release mode?

Difficult to say precisely but, mostly 1-2 secs although I have noticed on some occasions where the remote web service might be sleeping, the call can take up to 30 secs to respond which gives the UI ample time to refresh.

As far as testing goes, I do always test it in Release mode and on actual hardware, no emulator.

Thanks
 
Upvote 0
Top