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
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified
Accepted Solution

Loading screen not popping up

[ Edited ]

I am working on a code which was developed by my colleague. I think there is some flaw in the design level. I am trying to put a loading screen when navigating from SCREEN A -> SCREEN B.

 

The reason for using loading screen is, SCREEN B's data is obtained from network, contacting server, parsing with EVENT THREAD, in the fieldchange listener of the button field I am having this code.

 

public void fieldChangeListener(field a, int context)

{

    UiApplication.getUiApplication.pushScreen(loadingScreen);

 ---------------------------->>>POINT A

UiApplication.getUiApplication.invokeAndWait(new Runnable()

{

//********** Network Connection, SAX Parsing, etc

}

);

 

if(conditon for next screen)

{

 //************Condirion for next screen

SCREEN B or SCREEN C or SCREEN D

}

}

//-------------------------------->>>POINT B

 

The popup screen is missing or sandwiched inbetween A and B, occuring once I move back from B.

 

when code between POINT A and POINT B is commented out, loading screen is occuring.

 

Help of any sort is appreciated!!

 

A Y.

 

 

 

Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Loading screen not popping up

Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Loading screen not popping up

Hi avi_yach,

 

The problem is that the connection is running on the UI thread and blocks your loading screen (the invokeAndWait runs before the pushScreen) and once the connection is over, you are pushing a new screen which hides/dismisses the loading screen.

 

Another useful link is this:

http://supportforums.blackberry.com/t5/Java-Development/Sample-quot-Please-Wait-quot-screen-part-1/t...

 

Hope that helps,

 

E.

Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: Loading screen not popping up

Thanks for your reply Pankaj, but thing is I am pushing a screen on to the stack which is not visible, and it is visible when I navigate back.

Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Loading screen not popping up

HI,

can you paste here your code. how you are pushing your screen.

Thanks
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: Loading screen not popping up

Pankaj, I pasted the code snipet above.. but I cannot share my full code but that is the order in which I am doing..

Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: Loading screen not popping up

Thanks for your reply Erez, I coded with PushScreen(loadingscreen); inside the invoke and wait but what is happening is, Say I am navigating from Screen A to Screen B and l am pushing Loading screen in between, the loading screen is not visible immediately, Screen B is appearing and when I pop Screen B I can see loading screen. 

 

A dialog box without a button can cater my requirement. But is it possible?

 

A Y.

Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Loading screen not popping up

Hi,

Make changes in that code, according to your use. or post your entire code.

Thanks
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Loading screen not popping up

Hi A.Y.

 

The fact the you see your loading screen when you pop Screen B is because you do push the loading screen before Screen B and you do not remove it from the stack. So when ever you close Screen B, You will see the screen below it -> your loading screen.

 

The first thing that you should fix, is to remove the connection from the UI thread and put it on a different thread. Do not use any of the invoke methods as they are running on the UI thread.

 

Once you will do that, you will encounter the next issue, which is how to dismiss your loading screen and push screen B.

The solution for this is in Peter's tutorial which is in the link I posted above. Read carefully on the Observer design pattern usage.

 

Regarding your last question about dialog screen without button, you can use popup screen where you don't have to add any buttons.

 

Hope that helps,

 

E.

 

Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: Loading screen not popping up

[ Edited ]

Erez,

 

Thanks for your reply! that was of great help!

========================================================================================

 

The problem is with the design pattern, the loading screen is popped when I am navigating from ScreenA to Screen B, but it is not visible because, the SCREEN A (which is still visible) is still performing network connection action at the end of which I am popping Screen B! So,  the loaded popscreen without being noticed is covered By SCREEN B.

 

There are two possible way to do get what I need,

a) put the network thread in a seperate code

b) use a dialogue box!

 

Thought the problem is with the design pattern, I would like to mark this thread as closed!

 

A Y.