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: 59
Registered: ‎01-02-2009
My Device: Not Specified
Accepted Solution

sizeChanged repaint call control it?

[ Edited ]

Basically when you rotate the Storm it calls repaint().

 

So i have some code for this particular occurance, say we go from portrait to landscape....

 

//my code

//repaint()...

 

but then this happens...I think another repaint gets called, as I turned off my repaint and..it still repainted...

 

not to mention the fact that it always repainted to begin with when the phone was rotated...

 

Now... I want to stop the Storm from calling this extra repaint().

 

Protected Void SizeChanged(int w, int h){}

 

well that's just dandy...however repaint is still being called!

 

How do I stop the phone from repainting my images before my code for cropping the images has completed itself?

 

Well 2 things popped into my head just now...1 I could just make 2 seperate images and if i'm gonna change one of them simply set a variable for that.

 

However that doesn't help me miles down the road when I have a bunch of other stuff i'm gonna have to repaint and move over etc.

 

What would help is if I'm in control of the repaint call. Which frankly I know for a fact i'm not.

 

So what should I do to stop this pesky repaint from getting called?

 

 

heres a thought I just had..maybe set a variable for all repaints, and when I unlock the variable the repaint can get called...so...

 

boolean repaintingisok = false;

 

and then when I call repaint

 

repaintingisok = true;

 

and then after my repaint

 

repaintingisok = false;

 

Wow..even when posting on the forumns i find solutions...but It's still good I posted this..as I shouldn't have to do that.

 

Is there anyway to regain control of the repaints via..say the coder does override 

 

protected void sizeChanged(int w, int h){}

 

shouldn't the code then only repaint if the coder says for it to repaint....

 

well for now imma try my solution listed in this post...to set a variable for allowing repaints..and then i'll change it when I call repaint in my code.

 

 

 

 

Note: Please refer this thread to an existing one if there is one..I have yet to find one though....

 

 

 

 

 

Message Edited by javalover53 on 04-14-2009 10:37 AM
Message Edited by javalover53 on 04-14-2009 10:39 AM
/************** BelowZeroSoft ***********

www.belowzerosoft.com

Using creativity to blow your mind through software 1 step at a time.

*/
Developer
Posts: 293
Registered: ‎02-25-2009
My Device: Not Specified

Re: sizeChanged repaint call control it?

Hi,

 

r u using cavas or blackberry canvas or Blackberry native screen ? if you r using blackberry MainScreen , layout(int width,int height) method is called everytime the screen size gets changed. so it is like sizeChanged() method of canvas. So if u r using MainScreen, just put ur cropping code or whtever code in thiws layout mehod. this method will give you changed, width and height . So just decide on these variables , tht u r in now portrait or landscape mode and on the basis of it, just draw ur other image or cropped image.

Highlighted
Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: sizeChanged repaint call control it?

Hi,

 

May be this will help you out

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=23258&query.id=38...

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 59
Registered: ‎01-02-2009
My Device: Not Specified

Re: sizeChanged repaint call control it?


amardeepjaiman wrote:

Hi,

 

r u using cavas or blackberry canvas or Blackberry native screen ? if you r using blackberry MainScreen , layout(int width,int height) method is called everytime the screen size gets changed. so it is like sizeChanged() method of canvas. So if u r using MainScreen, just put ur cropping code or whtever code in thiws layout mehod. this method will give you changed, width and height . So just decide on these variables , tht u r in now portrait or landscape mode and on the basis of it, just draw ur other image or cropped image.


First off i'm using canvas...

 

second of all when putting my code in the sizeChanged method, the problem is repaint gets called too early. If I tilt the device over and over and over eventually I see a bad paint of my image. This is because i'm cropping the image and it decides to try and paint that crop during the crop. I've tried all kinds of variables to stop this from happening and so far the only thing that has worked has been to prevent the "automatic" repaint call, by telling my paint method "only paint when I say so" I used a boolean which i only set to true when I call repaint...so the other repaint that gets called has no authority over mine. 

 

Thanks for the attempt at helping me though. :-)

 

Still trying to work this one out...

 

In short the problem is when the user tilts the phone ridiculous amounts of times it causes a screen glitch.

/************** BelowZeroSoft ***********

www.belowzerosoft.com

Using creativity to blow your mind through software 1 step at a time.

*/
Developer
Posts: 59
Registered: ‎01-02-2009
My Device: Not Specified

Re: sizeChanged repaint call control it?

a word to the wise...

 

searching your code for the line...

 

repaint();

 

won't necessarily find "all" the repaints. Especially if you were given a code snippet which contained

 

repaint(0,14,20,0);

 

or something rediculous like that.

 

I feel like such a jackass.

 

I just spent 2 days scratching my head going "why...what is going on here?" and finally isolated the issue and discovered that nasty repaint

 

existing in a thread.

 

I haven't even tested and I know for a fact that the sizeChanged occurance is going to cause 1 of 2 things. Either it won't repaint at all unless I call repaint(). <---------- this would be nice....

 

or it will repaint in which case i'd have to look out for this.

 

But the good news is none of these things seem to actually be the issue. As the issue was a line of code completely unrelated to the job blackberry did in making.

 

void sizeChanged(int w, int h){}

 

 When I figured this out the first thing that popped in my head was "GO POST ON THE FORUM!"

 

I'm sorry for this wacked out post and the assumptions I made towards the existing function. I guess sometimes when coding it's easy to point fingures and play the blame game instead of quadruple checking to see if you yourself made the mistake.

 

I'm gonna just click on solution and close this issue out.

 

Let it be known though, if sizeChanged does call repaint on it's own..this might be a problem if you want to call repaint at your own leisure...i'll post a response in about 5 minutes as to if that happens or not. I think it does...because I remember earlier when I first got code running on the storm if I rotated all my stuff got repainted in the wrong direction which is why I had to lock the screen orientation. We'll see though....

/************** BelowZeroSoft ***********

www.belowzerosoft.com

Using creativity to blow your mind through software 1 step at a time.

*/