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
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Problem in displaying the loading screen.

Hi

 

I have created a new PopUp screen that contains the loading image...

Here is the code

public NewPopUp()
	{
		super(new VerticalFieldManager(NO_VERTICAL_SCROLL | USE_ALL_HEIGHT|USE_ALL_WIDTH));
	 		
		cc = new ComponentCanvas(displayWidth, displayHeight);
		add(cc);
	 		
		horizontalManager  = new HorizontalFieldManager(Manager.USE_ALL_HEIGHT| Manager.USE_ALL_WIDTH);
		cc.add(horizontalManager,displayWidth/2-gifEncodedImage.getWidth()/2,displayHeight/2-gifEncodedImage.getHeight()/2);
				
		AnimatedGIFField1 animatedGifField = new AnimatedGIFField1(gifEncodedImage, Field.FIELD_VCENTER);
		horizontalManager.add(animatedGifField);
	 	
		setBackground(BackgroundFactory.createSolidTransparentBackground(Color.WHITE, 0));
		setBorder(BorderFactory.createRoundedBorder(new XYEdges(), Border.STYLE_TRANSPARENT));
	   
	}

 

I want when i click on the image this screen gets displayed first and then the CustomThread runs.

So i am doing like this..

 

imageField = new BitmapField(image,BitmapField.FOCUSABLE)

{

protected boolean navigationClick(int status, int time)
{

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

 

CustomThread thread = new CustomThread();

thread.start();

}

};

 

 

But when i click on imageField first the thread gets called after the thread functionality completed, i get the loading screen. 

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in displaying the loading screen.

Seems like you Thread is grabbing the EventThread or the EventLock.

 

Replace your CustomThread with a simple Thread that just issues a sleep for say 5 seconds, and see if the problem still occurs.  If it does, then can we see the simple Thread code. 

Please use plain text.
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in displaying the loading screen.

Hey

Thanks for the reply.

I have done the way you said.

 

Actually i have to run two threads , on the click of a button.

If i use only single thread then i am getting the loading screen but if i use two threads then loading screen does not displays.

 

And thread1 must join before thread2 gets start.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in displaying the loading screen.

Some debugging logic applies, just apply it to both Threads. 

 

Seems like one (or both) of your Threads is grabbing the EventThread or the EventLock.

 

Replace your Threads with two simple Threads that just issue a sleep for say 5 seconds, and see if the problem still occurs.  If it does, then can we see all code. 

Please use plain text.
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in displaying the loading screen.

I have replaced the customthread with the simple Thread.

1st thread is getting lat and long and in secon thread i am sending this latitude and longitude to the webservice to get the response.

 

 

So i am doing like this...

 

1)pushing the popup screen.

2)Thread 1 started

3)thread1 must join first

4)if i didn't get the lat and lon,displays the dialog box

5)else start the second thread.

 

Now i am not getting the PopUp screen when i click on the bitmapfield.

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in displaying the loading screen.

In general, the approach you are taking should work.  The Popup should appear. 

 

However I am confident you have a coding bug that is resulting in your code holding the event thread or event lock.  I suspect it is related to the join.

 

The easiest way for us to resolve that is to see your code and then show you what is wrong in your code, but we do not want to wade through bucket loads of your code to help. 

 

So please do what I ask, replace BOTH your Threads with simple sleep, if the problem stil occurs, then show us your code.  You should be able to replicate this problem in less than 20 lines of code.  That is all we want to see. 

 

Clear now?

Please use plain text.