Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
radpin
Posts: 21
Registered: ‎07-15-2008
My Device: Not Specified

hoping to get pointed in the right direction

I was hoping that someone might be able to steer me in the right direction in regards to displaying a popupscreen from a timer task thread. Basically I have a class that kicks off a timer, and goes off and does thing. Everything's working great.

 

But when I try to close the popupscreen, I get all kinds of haywire. So far I've just been copying and pasting different code snippets from the forum, hoping it would magically fix my problems. I was hoping someone could point me in the right direction so I can learn for real how to do this.

Developer
radpin
Posts: 21
Registered: ‎07-15-2008
My Device: Not Specified

Re: hoping to get pointed in the right direction

I found this article:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

 

But I'm really looking for a screen that I can add fields and field listeners to.

Developer
Nadirfirfire
Posts: 192
Registered: ‎01-12-2010
My Device: Bold

Re: hoping to get pointed in the right direction

try using this for splashscreen may be this might help

 

package zeo;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
public class SplashScreen extends MainScreen{
    Bitmap bmp,bmp1;
    ProgressBar p;
    
    public SplashScreen(){
            bmp = Bitmap.getBitmapResource("transparentzajil.jpg");
               p = new ProgressBar(50,50);
              p.start();
        
    }
    public void paint(Graphics g){
          //g.drawBitmap(0,0,bmp.getWidth(),bmp.getHeight(),bmp,0,0);
    	g.drawBitmap(60, 110, 320, 239, bmp, 0, 50);
    	//g.drawBitmap(x, y, width, height, bitmap, left, top)
    }
    
    
}

class ProgressBar extends Thread{
    public int iterations;
 public int maximum, timeout;
    private boolean useful;
    ProgressBar(int maximum, int timeout)
    {
//);
           
           this.maximum = maximum;
           this.timeout = timeout;
           
    }
   public void run() 
   {
        useful = true;

        UiApplication.getUiApplication().invokeAndWait(new Runnable(){
            public void run(){

            }
         });

iterations = 0;

         while (useful){
            try{
                Thread.sleep(timeout);
            }catch (Exception e){
            }
            
            if (++iterations > maximum)
                remove();

       }
     
            UiApplication.getUiApplication().invokeAndWait(new Runnable() 
            {                
                public void run() 
                {

                    UiApplication.getUiApplication().pushScreen(new LoginPage());

                }
            });

  }

     /**
     * Method to shutdown the thread and remove the popup screen
    *  
    */

   public synchronized void remove() 
   {
            useful = false;
   }
}

 

Developer
fwest
Posts: 67
Registered: ‎10-14-2009
My Device: Not Specified

Re: hoping to get pointed in the right direction

what i would do is save the screen in some variable and give it a function to close itself

 

mock code:

 

myScreen extends popupscreen{

 

public void closeThis(){

     try{

           super.close();

          } catch(Exception e){

          }

     }

}

 

}

and just call that function. should work.

 

you could also do this:

MyPopUp screen = new MyPopUp();

Runnable r1 = new Runnable() {
     public void run() {
        UiApplication.getUiApplication().pushScreen(screen);
   }

};

 

UiApplication.getUiApplication().invokeLater(r1);

//do stuff, wait for timer and calculate 42

try {

     UiApplication.getUiApplication().popScreen(screen);

} catch (Exception e){

     System.out.println("error@pop");

}

-------------
blog: http://coding.westreicher.org
twitter: http://www.twitter.com/meredrica