Blackberry simple progressbar for BrowserField2

664 views Asked by At

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?

1

There are 1 answers

0
DecodeGnome On

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.