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
Highlighted
New Developer
Posts: 8
Registered: ‎03-20-2009
My Device: Not Specified
Accepted Solution

BitmapField.setBitmap not acting as expected.

Hi there.

I have a class which derives from BitmapField.

The intention of this class is to download an image from the net and update the display once the image is loaded.

 

Code is pasted here:

http://pastebin.com/f5b4de367

 

The callback happens in

public void wdcCallback(final String data)

 

However the image on screen does not update after calling invalidte() until i focus on the container of the BitmapFIeld or scroll the list which contains it.

 

I have tried a few different approaches to get the field to update as can be seen from the commented out lines.

But nothing seems to work.

 

Anyone have any suggestions?

 

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: BitmapField.setBitmap not acting as expected.

Have you tried invalidating the main screen also?

Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 8
Registered: ‎03-20-2009
My Device: Not Specified

Re: BitmapField.setBitmap not acting as expected.

 I eventually got it to work by invalidating the ListField within which the BitmapField is contained.

 What a pain in the **bleep**, i have to pass a reference from the ListField all the way down to the WebBitmapField

 

The Heirarchy is thus:

 

ListField

  |

  \---> HorizontalFieldManager

                  |

                  \-----------> WebBitmapField

                  

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: BitmapField.setBitmap not acting as expected.

I can see why you would have to do this.  The HorizontalFieldManager is not actually owned by any Manager so is not present on the Screen.  You are just using it to format the ListField row.  So the only component in your chain which is a real Field and has some real screen acreage is the ListField. 

 

A grubby way to do this would be to use getActiveScreen().invalidate().

New Developer
Posts: 8
Registered: ‎03-20-2009
My Device: Not Specified

Re: BitmapField.setBitmap not acting as expected.

But why does invalidating the bitmap itself not work?
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: BitmapField.setBitmap not acting as expected.

I don't think you can invalidate a Bitmap, I presume you mean invalidating the BitmapField.

 

My explanation is based around how I think you are drawing your Fields in the ListField.  I might be wrong. 

 

The key question is "Is the BitmapField actually included in a Manager that is included in the Fields added to the Screen?". 

 

It is included in a HorizontalFieldManager, but that Manager is, I'm guessing, managed as part of the drawListRow processing, so is never in itself, added on the Screen, it is just drawn on the screen.  So invalidate() will look to see which part of the Screen needs to redrawn, by determining the actual screen extent associated with the Field, and discover the Field is not actually added to any Screen.

 

Every Field has the possibility of a Manager.  if you do a 'getManager()' recursively on a Field, you should eventually get to the top Level Field, that will be a Screen.  If you do this to your ListField, you will get to the Screen.  However if you do this to your BitmapField, the chain will stop at the HorizontalFieldManager.  You never 'add' your HorizontalFieldManager to the ListField (and you can't anyway!). 

 

Hope this makes sense.