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
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified
Accepted Solution

GIF animated Dialog & HTTP connection

Hi

 

I have created a animated GIF dialog screen using Popup screen and I have to show it when an the application is connecting to server using httpconnection. So problem is when i create the dialog and show it on screen the network connection is not happeneing only animation thread runs.

 

For eg

 

I have a class called AnimatedDialog which draws the gif image using a thread.

My Httpconnection is awritten in a function connectToServer()

 

the way i called is

AnimatedDialog.show()

Thread t= new Thread(new Runnable({

public void run(){

connectToServer()

}});

t.start();

Any suggestion for implementing such a screen. I cannot update the animated dialog from HttpConnection. once the httpconnection is over the dialog i closed.

 

 

 

Please use plain text.
Contributor
jacobtabak
Posts: 34
Registered: ‎03-14-2010
My Device: N/A

Re: GIF animated Dialog & HTTP connection

Can you start the network connection thread before you open your dialog?  If it is a modal dialog I believe it will prevent any subsequent code from executing until it is closed.

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: GIF animated Dialog & HTTP connection

Depends on what you do inside your AnimatedDialog.show().  If you use UiApplication.getUiApplication().pushModalScreen(...) in there, that is what you'll get - it wont proceed until the screen is popped.

 

Why don't you reverse the order of actions?  For example:

 

Thread t = new Thread(new Runnable()
    public void run() {
        connectToServer();
        AnimatedDialog.hide(); // or pop it some other way
    }
});

t.start();

AnimatedDialog.show();

 This way you start the thread and show the Dialog indicating that you are (already!) doing some background operation...

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
SamuelD
Posts: 166
Registered: ‎01-14-2009
My Device: Curve 8330

Re: GIF animated Dialog & HTTP connection

Hello,

do you use pushModalScreen to show your popup?

 

PushModalScreen don't return until the popup is dismiss so the thread won't start. You can use pushScreen so the thread will be able to start right after.

Thank you, have a nice day.

--
Samuel D.
Please use plain text.
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Re: GIF animated Dialog & HTTP connection

Thanks for the reply

 

I will call the network thread and then only show the animated dialog.

I am using pushModalscreen

based on the reponse from the server only I am closing the dialog. The repsonse i am getting in the connectTOWeb function only

 

Can I use Push screen for showing the dialog ???

Please use plain text.
Developer
SamuelD
Posts: 166
Registered: ‎01-14-2009
My Device: Curve 8330

Re: GIF animated Dialog & HTTP connection

Hi,

if you push Screen, you'll need to handle key press so the user don't close your popup. Note that the connection timeout can be long so if there is no way to close the popup, this may be annoying.

 

You can take the end key to close the popup and cancel the request for example.

Thank you, have a nice day.

--
Samuel D.
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: GIF animated Dialog & HTTP connection

I've recently created a series of KB articles that talk about doing exactly what you want here.  Unfortunately these are still being reviewed.  However attached is the zip archive associated with the last of the articles.  Have a play with this code.

 

It is a JDE project, that will download a file to the SD Card.  There are two variations.  Options 1 will allow you to cancel the download, Option 2 will display percentage complete.  Obviously you could combine the options if you want.  But both options display an animated. gif.

 

Happy to take questions, comments etc. on the code.  Hopefully they will be published sometime soon and you can comment directly in the KB article.  .

 

 

 

Please use plain text.