BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-18-2009, 02:24 PM   #1 (permalink)
New Member
 
newbie_bb's Avatar
 
Join Date: Aug 2009
Model: 8300
PIN: N/A
Carrier: simulator
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default SplashScreen sample not working ...

Please Login to Remove!

Hi All,

I am trying to implement a splash screen on blackberry eclipse using JDE 4.7

I am taking the sample from the following link.

http: // w ww. blackberry. com / developers/javaknowledge/userInterface/kpa0206145537.shtml

I have changed the code a bit. but i think so not to the level that it should stops working.

As i dont want to use the keylistener i.e removing splash on key movement. I want to only use the thread and the splashscreen should get out automatically after some time.
I am attaching the code

Code:
class HelloWorldDemo extends UiApplication
{
    
    public static void main(String[] args)
    {
        HelloWorldDemo theApp = new HelloWorldDemo();
        theApp.enterEventDispatcher();
    }
    private HelloWorldDemo()
    {
        //pushScreen(new HelloWorldScreen());
        pushScreen(new SplashScreen(UiApplication.getUiApplication(),new HelloScreen()));
    }    
}

Code:
public class SplashScreen extends MainScreen {
    
    private MainScreen next;
    private Timer timer = new Timer();
    private UiApplication application;
    //private static final Bitmap _bitmap = Bitmap.getBitmapResource("wap_logo.gif");
    

    public SplashScreen(UiApplication ui, MainScreen next) {
        super (Field.USE_ALL_HEIGHT|Field.FIELD_LEFT);         
        this.application = ui;
        this.next = next;
        //this.add(new BitmapField(_bitmap));
        this.add(new LabelField("Loading ..... ",Field.NON_FOCUSABLE));
        
        /*SplashScreenListener listener =  
			new SplashScreenListener (this);
        
        this.addKeyListener(listener);
        this.addTrackwheelListener(listener);*/
        
        timer.schedule(new CountDown(), 5000);
        
        application.pushScreen (this);
    }
        
    public void dismiss() {
        timer.cancel();
        application.popScreen (this);
        application.pushScreen (next);
    }

    private class CountDown extends TimerTask {          
        public void run() {
           DismissThread dThread = new DismissThread();
           application.invokeLater(dThread);
        }
    }
    
    private class DismissThread implements Runnable {
        public void run() {
             dismiss();
        }   
    }      
}
Please let me know where i am doing wrong.

Requirment: My requirment is to show a screen temprorarly while my application collects some vital information from other site. After some stipulated time that screen should be replaced by actual application screen.

Please provide the sample code in case any one have other solution that the above i am trying.
__________________

Thanks,
Regards,
Amber
Offline  
Old 09-20-2009, 11:54 PM   #2 (permalink)
New Member
 
Join Date: Apr 2009
Model: 8800
PIN: N/A
Carrier: Software developer
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is another solotion. First display the SplashScreen and then call the information collecting method (this case it is fetchData() ) in a separate thread. After finishing the info collection task, update the UI screen if required (this case it is refresh() ) and finally popup the SplashScreen from UI stack.

Code:
UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    SplashScreenscreen = new SplashScreen();
                    UiEngine ui = Ui.getUiEngine();
                    ui.pushModalScreen(screen);  
                }
            });
            Thread thread = new Thread() {
                public void run() {
                    fetchData(); // use this method to collect your vital information
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            refresh();  // use this method to update any information to the MainScreen 
                            UiEngine ui = Ui.getUiEngine();
                            Screen screen = ui.getActiveScreen();
                            if (screen instanceof SplashScreen)
                                ui.popScreen(screen);
                        }
                    });
                }
            };
            thread.start();

Here SplashScreen class may be just an instance of Screen class having the required display contents. You can place above code in the screen which is currently being displayed and invoke it when you need to display the splash screen.

Cheers,

-Kelum-
Offline  
Old 09-21-2009, 07:25 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: T-Mobile
Posts: 67
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Loading class for BlackBerry
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.