0

In my app I have a BrowserField2 loading different pages and I want to show a simple spinning progressbar/indicator. As simple as possible really, without percent etc. - just a small animation to indicate to the user that something is happening.

I come from Android development and there such a thing is called Progressbar, though for Blackberry it maybe is called something completely different? (Progressbar for Blackberry seems to always include calculating the progress made).

What should I be looking for?

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
DecodeGnome
  • 1,809
  • 1
  • 19
  • 36
  • You may take one gif image; and create one popupscreen and in that you do like this link: http://stackoverflow.com/questions/7605919/loading-gif-image-on-above-bitmap-field-in-blackberry/7606108#7606108 which I posted and in that popup screen take one labelfield like "Please wait" and add to it; – alishaik786 Jan 24 '12 at 09:58
  • Thanks, the only problem is that this blocks the UI. – DecodeGnome Jan 24 '12 at 13:02
  • Well I guess I could write an answer and accept it but I will when I have solved this in a way so that the small animation doesn't block the entire UI. Not happy with the solution yet. – DecodeGnome Jan 24 '12 at 14:12

1 Answers1

1

I solved it in a rather unorthodox way, something I probably wouldn't recommend ANYONE but I'll write it anyway since maybe it will help someone who's in a hurry to get it done. Just remember this is a bad way of doing it.

My app basically consists of 4 buttons and a browserfield.

To display a spinning "load animation" I use alishaik786's tip (see his comments) of the custom PopupScreen triggered by a browserfieldlistener:

// BrowserFieldListener to catch when a page started loading and when it is finished
                BrowserFieldListener listener = new BrowserFieldListener() {

                            public void documentCreated(BrowserField browserField, ScriptEngine scriptEngine, Document document) throws Exception{
                                displayLoadAnimation(); 
                               // see method below
                            }           

                            public void documentLoaded(BrowserField browserField, Document document) throws Exception{
                                try{
                                    popUp.close();
                                }catch(IllegalStateException es){
                                    es.printStackTrace();
                                }
                            }
                        };

            // The method for showing the popup
            private void displayLoadAnimation(){

                    popUp = new LoadingPopupScreen();

                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            UiApplication.getUiApplication().pushScreen(popUp);
                        }
                    });
                }

Then in my custom PopupScreen I check where the user is clicking in "protected boolean touchEvent(TouchEvent event)" by checking event.getGlobalY() & event.getGlobalX() of the touch and comparing it to the positions of the buttons. If the user presses within the X&Y of a button then the popup screen is closed and I trigger the button being pressed.

As I said this is a bad way of doing it (many things need to be static), but it works if you want a quick and dirty sollution.

DecodeGnome
  • 1,809
  • 1
  • 19
  • 36