Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 86
Registered: ‎11-19-2008
My Device: Not Specified

How to show the busy/loading icon??

Hi guys,

in my app I have a few custom-made search functions that can easily take 2 or 3 seconds. While the search is doing its work, I'd like to programmatically show the rotating busy/wait icon that the system shows on its own in other sitations. Is that possible? I don't like to have an app that seems forzen for 2 secs....

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: How to show the busy/loading icon??

I'm not sure if there is a programmatic way but if that is really what you want

you could call the gc which AFAIK automatically puts it up or do something to provoke it, like 

floodthe message queue. I've got one piece of developmental code that normally just gets an hour glass

because it takes forever to respond ( I compose an email based on program status and then send it all

from UI thread, can take a minute or so).

 

You may want to consider design options that keep things going - not that I want to

take away from the glory of the modal dialog box, but generally with

a little thought you can keep the system "open" under a lot of conditions

that usually cause designed lock outs.

 

For example, I have many options that handle user requests to go get something from a server- either

book marks, or points of interest based on gps info,etc. These could take seconds or minutes to get, but

there is no point holding everything up. In the first case, I put up a confirmation box when things

are recieved, during which time you can exit app or otherwise navigate. In the other case, you can

change parameters and even queue up more requests for different sets of "interest points." These

ultimately put up confirmation boxes too but they aren't really required as when recieved they

are added to relevant menu's.

 

If you are really only taking a few seconds and using the CPU, personally I'd get annoyed knowing you slowed

things down wasting system resource putting up a rotating hour glass...

 

 

 

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to show the busy/loading icon??

You could utilize the Status dialog (see the API docs). This is not a perfect solution but does (basically) what you want.

 

Another option is to put a gauge field on a popup dialog, and implement the ActiveObject pattern to keep the guage updated and synchronized with the search function, without holding the event thread. More work but slightly more pleasing. I can tell you for certain that if you perform your (2-3 second) search in the event thread, you will sooner or later precipitate an event queue overflow which will then result in the OS killing your application as "unresponsive".

 

 

 

 

 

Highlighted
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: How to show the busy/loading icon??

AFAIK you can hang the UI thread and it does seem to put up the hour glass - my program status

option works fine for its intended purpose. But, if it was a "real" option, for real people and not

just developers, you could do it just fine on another thread and let the "User", eh "use" his phone

not just sit there watching the hour glass spin. If it really only is 2-3 seconds its doesn't matter

much but if you expect longer, the user can put you in bg and check his mail or something

while waiting.You could even let your thread yield from time to time etc. Obviously, you would have

to think about off loading to a real computer or something but if you need to do

something locally there are options besides hanging the phone.

 

Certainly with network IO the ability to "fire and forget" is nice as you can make a request, forget about

it until it is done, and then formulate the next ones.

 

Also, re the gauge field, I finally decided it is pretty easy and well worth the effort to make

your own. Paiinting is just some variant of fractionally filling  a rectangle or whatever else you like.

In a recent app, I have instrumented network IO and can integrate all the queued requests

into a unified status thing.