Skip to main content

Animation and Network Call?

3 replies [Last post]
ashish_onmobile
Offline
Joined: 2009-05-28

Hi Friends,

I want to display animation while getting data from server. So I implemented it in following ways,

1)

</p>
<p>public void actionPerformed(ActionEvent evt)<br />
{<br />
     if(evt.getCommand() == cmdConnect)<br />
       {<br />
           /* now display loading Message which is Dialog Box. I implemented animation from  AnimationDemo.java in LWUITDemo. */<br />
          dialog.show(); // where dialog is instance of Dialog which contains one button which use to display animation.<br />
          // Now call function to get data from server which is written in separate thread.<br />
          byte data[] = getNetworkData(url);<br />
       }<br />
}</p>
<p>

When I call above code. It display the animation but getnetworkData function never get called . :(

2)

</p>
<p>public void actionPerformed(ActionEvent evt)<br />
{<br />
     if(evt.getCommand() == cmdConnect)<br />
       {<br />
           /* now display loading Message which is Dialog Box. I implemented animation from  AnimationDemo.java in LWUITDemo. */<br />
          dialog.show(50, 50, 50, 50, false,false);; // where dialog is instance of Dialog which contains one button which use to display animation.<br />
          // Now call function to get data from server which is written in separate thread.<br />
          byte data[] = getNetworkData(url);<br />
        }</p>
<p>}</p>
<p>

now for above code it does not display any animation and it is able to get data from server. But i want to display animation too.

Is there any body who can help me?

Thanks in advance.

Regards,
Ashish

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
anupsth
Offline
Joined: 2009-05-21

try this:

if(evt.getCommand() == cmdConnect)
{
new Thread(){
public void run(){
byte data[] = getNetworkData(url);
dialog.dispose();
}
} .start();
dialog.show();
}

anupsth
Offline
Joined: 2009-05-21

Try this:

public void actionPerformed(ActionEvent evt)
{
if(evt.getCommand() == cmdConnect)
{
new Thread(){
public void run(){
dialog.show();
}
} .start();

byte data[] = getNetworkData(url);
dialog.dispose();
}
}

ashish_onmobile
Offline
Joined: 2009-05-28

Thanks for your response anuspth.

It is working..

But I have more question.

Displaying a dialog box takes time. Do you know how can I optimize it.

If I execute following code it takes near about 700 ms in emulator.
dialog = new Dialog();

So What should I do. Should I create it or use static methods of Dialog to show it.

Regards,
Ashish