Blackberry - Loading/Wait screen with animation

匿名 (未验证) 提交于 2019-12-03 02:08:02

问题:

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!

回答1:

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 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!