Is there a way to show "Loading" screen with animation in blackberry?
Options:
- PME animation content
- multithreading + set of images + timer/counter
- standard rim api
- some other way
Any of this?
Thanks!
Is there a way to show "Loading" screen with animation in blackberry?
Options:
Any of this?
Thanks!
Fermin, Anthony +1. Thanks to all, you gave me the part of answer.
My final solution:
1.Create or generate (free Ajax loading gif generator) animation and add it to project.
2.Create ResponseCallback interface (see Coderholic - Blackberry WebBitmapField) to receive thread execution result:
public interface ResponseCallback { public void callback(String data); }
3.Create a class to handle your background thread job. In my case it was http request:
public class HttpConnector { static public void HttpGetStream(final String fileToGet, final ResponseCallback msgs) { Thread t = new Thread(new Runnable() { public void run() { HttpConnection hc = null; DataInputStream din = null; try { hc = (HttpConnection) Connector.open("http://" + fileToGet); hc.setRequestMethod(HttpsConnection.GET); din = hc.openDataInputStream(); ByteVector bv = new ByteVector(); int i = din.read(); while (-1 != i) { bv.addElement((byte) i); i = din.read(); } final String response = new String(bv.toArray(), "UTF-8"); UiApplication.getUiApplication().invokeLater( new Runnable() { public void run() { msgs.callback(response); } }); } catch (final Exception e) { UiApplication.getUiApplication().invokeLater( new Runnable() { public void run() { msgs.callback("Exception (" + e.getClass() + "): " + e.getMessage()); } }); } finally { try { din.close(); din = null; hc.close(); hc = null; } catch (Exception e) { } } } }); t.start(); } }
4.Create WaitScreen (a hybrid of FullScreen and AnimatedGIFField with ResponseCallback interface):
public class WaitScreen extends FullScreen implements ResponseCallback { StartScreen startScreen; private GIFEncodedImage _image; private int _currentFrame; private int _width, _height, _xPos, _yPos; private AnimatorThread _animatorThread; public WaitScreen(StartScreen startScreen) { super(new