06-09-2010 01:42 PM
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.
Solved! Go to Solution.
06-09-2010 02:38 PM
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.
06-09-2010 02:39 PM
Depends on what you do inside your AnimatedDialog.show(). If you use UiApplication.getUiApplication().pushModalScreen(.
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...
06-09-2010 02:40 PM
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.
06-09-2010 02:47 PM
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 ???
06-09-2010 02:52 PM
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.
06-09-2010 05:31 PM
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. .