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
Contributor
ZevsVU
Posts: 20
Registered: ‎05-17-2012
My Device: have no device
My Carrier: KievStar
Accepted Solution

Redraw images after device rotation

Hi, to all)

 

I need redraw my interphace after device rotation...

 

in myScreen i have a method

 

public LoginScreen()
{
scaleKoof = Display.getWidth()/320.0f;
// Create interface elements

}

 

If i coluld call this after rotation again all might be good! how i can do it?

scaleRotation - scale all images in my interpace...

Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Redraw images after device rotation

overwrite sublayout and check the dimensions, it is called after a rotation.
----------------------------------------------------------
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
Please use plain text.
Developer
darkberry
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Redraw images after device rotation

I'm trying to do the same, but the dimensions returned by Display.getWidth or Display.getHeight, or even the value returned by Display.getOrientation do not change at all. I even tried using an invokeLater 1.5 secs after the method is called and still is returning the old values. This is the overriding method in my MainScreen class:

public void sublayout(int width, int height){
	super.sublayout(width,height); //Tried calling this in the last line as well with identical result.		
	
	System.out.println(">>>>>>>>> Display.getWidth(before): " + Display.getWidth());
	System.out.println(">>>>>>>>> Display.getOrientation(before): " + Display.getOrientation());
	
	UiApplication.getUiApplication().invokeLater(new Runnable(){
		public void run() {
			
			System.out.println(">>>>>>>>> Display.getWidth(later): " + Display.getWidth());
			System.out.println(">>>>>>>>> Display.getOrientation(later): " + Display.getOrientation());
		}
	}, 1000, false);
}

 I need to stick to 4.5 OS, so I can't even lock the screen in one direction because I'll need to compile for 4.7. What other way of detecting screen dimensions are there other than the Display class? Is there a trick or something I'm doing wrong or missing?

 

Why are the Display methods still returning old values????

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

Re: Redraw images after device rotation

I thin arkadyz has noted this and suggested that you should focus on using the dimensions that are given to you in sublayout.  For example, if you have a VFM, then the width is normally the full width of the device.  So you can save the value as it was last time you did it, and if it changes rework your assets to match.

 

In this case, can you confirm that Display.getWidth() in sublayout is the same after a rotation as it was when your first laid out.  Retain the value last used and see if it has changed. 

 

BTW I believe that sublayout will get called when the virtual keyboard appears.  In this case the height changes.  I suggest just comparing the width to detect tilts so as you are not confused by height changes. 

Please use plain text.
Developer
darkberry
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Redraw images after device rotation

Yes, that was how I was trying to do it. But neither the arguments or the Display values change. I've read other posts suggesting that the API only updates the Display values after calling sublayout, so I tried with invokeLater. Unfortunately, even launching the runnable 2 seconds after the sublayout callback is not enough. Looks like these values are cached for a given screen.

 

Then I came to this post

There you suggested to check the values in a new screen pushed just for this purpose. That made me think that maybe the API is caching the values in a per-screen basis. But again it is not working for me.

 

I'm getting out of ideas.

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

Re: Redraw images after device rotation

I have not had this sort of issue.  Can you tell me what OS you are developing on and what you are testing with.  Perhaps a sample screen to demonstrate the problem too?  That would make it easier for everyone to test. 

Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Redraw images after device rotation

and maybe move the discussion into a new thread instead of performing thread necromancy on somebody elses solved one.
----------------------------------------------------------
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
Please use plain text.
Developer
darkberry
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Redraw images after device rotation


simon_hain wrote:
and maybe move the discussion into a new thread instead of performing thread necromancy on somebody elses solved one.

Ok, I'll do as you say. But I disagree in the "somebody else's question" part. I think questions belong to the development community as a whole, and the fact that is solved is of little importance to me, as I'm having exactly the same issue. Posted here my case since Google's first result for my search was this, and I thought posting exactly the same question again would be frowned upon.

Please use plain text.