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
Posts: 809
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later
Accepted Solution

Loader

Hi, I am using blackberry 7.0.0 jdk.I want to implement loading function.

for example, i am in my application i click to go to new page...once this page is trying to open..i want in middle of screen to show picture loading.... how can it be done?

Developer
Posts: 16,791
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Loader

check peters samples:
http://supportforums.blackberry.com/t5/Java-Development/Sample-quot-Please-Wait-quot-screen-part-1/t...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 809
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Loader

[ Edited ]
        	HorizontalFieldManager popHF = new HorizontalFieldManager();
            popHF.add(new LabelField("Pls wait..."));
            final PopupScreen waitScreen = new PopupScreen(popHF);
            
            new Thread()
            {
                public void run() 
                {

                    synchronized (UiApplication.getEventLock()) 
                    {
                    	UiApplication.getUiApplication().pushScreen(waitScreen);
                    }
                    synchronized(GlobalValue.getTop20)
                    {
			        	if(GlobalValue.getGetTop20().size() == 0)
			        		MAMClient.getTop20(GlobalValue.getGetTop20(), catId);

                    }
            synchronized (UiApplication.getEventLock()) 
             {
                 UiApplication.getUiApplication().popScreen();
             }
            return;
          }
                
      }.start();
	 final VerticalFieldManager Content= new VerticalFieldManager(Manager.USE_ALL_WIDTH|Manager.VERTICAL_SCROLL); Content.setMargin(5,0,0,0); int mas = 0 ; while(mas < GlobalValue.getGetTop20().size()) { Song temp = (Song) GlobalValue.getGetTop20().elementAt(mas); Content.add(new A_AddSingersFM(temp.songId, temp.songName, false,temp.albumCover,temp,-1, tb, logIn,logOut,1,0,0, Register)); mas++; } tab1Manager.deleteAll(); tab1Manager.add(Content); 

 

 

 

I have this going, on mamclient.gettop20 i go and get data from the internet....

but what happens? it does it..but after thread is over i want to display the bolded part in the tab..yet it doesnt it displays blank ..

 

if i take bolded part and throw it inside thread too..( exactly after mamclient.gettop20) i get illegalstateexception

 

 

Developer
Posts: 16,791
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Loader

if you manipulate the ui from a separate thread you have to use invokelater.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 809
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Loader

 Thread threadToRun = new Thread() 
            {
                public void run() 
                {

                    synchronized (UiApplication.getEventLock()) 
                    {
                    	UiApplication.getUiApplication().pushScreen(waitScreen);
                    }
                    synchronized(GlobalValue.getTop20)
                    {
			        	if(GlobalValue.getGetTop20().size() == 0)
			        		MAMClient.getTop20(GlobalValue.getGetTop20(), catId);
                    }
            synchronized (UiApplication.getEventLock()) 
             {
                 UiApplication.getUiApplication().popScreen();
 			  	final VerticalFieldManager Content= new VerticalFieldManager(Manager.USE_ALL_WIDTH|Manager.VERTICAL_SCROLL);
 					Content.setMargin(5,0,0,0);
 					int mas  = 0 ;
 					while(mas < GlobalValue.getGetTop20().size())
 					{
 						Song temp = (Song) GlobalValue.getGetTop20().elementAt(mas);
 						Content.add(new A_AddSingersFM(temp.songId, temp.songName, false,temp.albumCover,temp,-1, tb, logIn,logOut,1,0,0, Register));
 						
 						mas++;
 					}
 					tab1Manager.deleteAll();
 				    tab1Manager.add(Content); 
             }
            return;
          }
                
      };
      			threadToRun.start();

 

 

 

This solved my problem.