BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-22-2009, 10:06 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help me - ObjectListField Image

Please Login to Remove!

could anyone help me to put an image on objectlistfield please. I have the drawListRow working fine to put my text data in but my image is stored as a bitmap variable in the object the list shows and when i try to get the object.productImage and then drawBitmap it's says the image is null. It has to be stored in the object currently as i am converting an image url to an image on creation of the object and storing the image as a bitmap (productImage), if i were to conert the image from the url in the drawlistrow method it trys to get the image everytime i scroll down. And it doesn't even show it!


Please help me if you can, been at it for a day now! Surely this has been done before - basicallly get an image url and converting this into an image and then adding it to the objectlistfield before the row is painted.

Regards

Brendan
Offline  
Old 08-22-2009, 02:16 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If anyone needs any further information please just ask, I have exhausted every possible chance of solving this myself so i'm gonna need one of you! please.
Offline  
Old 08-22-2009, 03:24 PM   #3 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I do not understand the problem as you have described it, and I doubt if anyone else will, either.

Can you explain how you are "converting the image URL to an image" ?
Offline  
Old 08-22-2009, 04:06 PM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The conversion happens by a class that recives the url as a string, creates an image for me then just to call it's getBitmap() method. the class was given to me by a site (I will post the link to the class code in the next post as i'm not allowed in my ninth post!)
This converter class does work btw, I have it loading an image in the class itself - I have extended screen. I just can't seem to access the productImage externally??
I am so new at this so please forgive meif i have done it wrong but i populated my extended objectlistfield with product objects - this object contains 6 string variables and a image (bitmap) variable. I create the product object dynamically by splitting a string, on creation of the object it calls the class to convert prouctImagePath. I can get access to the product by this code

public void drawListRow(ListField listField, net.rim.device.api.ui.Graphics g, int index, int y, int width)
{
Product[] data;

Product p = (Product) get(listField, index);

but when i access the productimage variable it returns null. Doesn't matter how I access it, directly or indirectly. So is there something i could try or am i doing this process wrong. I can access the products string variable in drawlistrow but not the image.

as a workaround, i though about calling the converter class in the drawlistrow method itself, but everytime there is interaction with objectlistfiled there is network action, but never no image on my objectlistview.
Offline  
Old 08-22-2009, 04:35 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You do not want to be converting images in the drawListRow method.

Have you tried single stepping the code in the debugger? Also try some strategic System.out statements? If the Bitmap was created correctly, then it is either a) not being stored correctly as you think, or b) somehow it is getting clobbered.
Offline  
Old 08-22-2009, 04:57 PM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
You do not want to be converting images in the drawListRow method.

Have you tried single stepping the code in the debugger? Also try some strategic System.out statements? If the Bitmap was created correctly, then it is either a) not being stored correctly as you think, or b) somehow it is getting clobbered.
Debgged my last 24 hours away! I know whereever i do my defensice programming i get a null pointer exception

public Product(String productId, String productName, String productPrice, String productOffer, String productOfferValidity, String productImagePath, String productRating, String productQuantity)
{
this.productImagePath = productImagePath;
if(this.productImagePath != null)
{
try
{
image = new WebBitmapField(productImagePath + ";" + "deviceside=true;apn=wap.o2.co.uk;tunnelauthuserna me=o2wap;tunnelauthpassword=password");
this.productImage = image.getBitmap();


everytime i construct a product it passes this code and there aare enough outputs in event log to tell me that the image is being received so the string variables are accessible, the event log tells me the image is being retrieved(and i know the class converter works), i just get a nullpointerexception at drawbitmap if i don't check for null before. if i check for null before i don't get to drawbitmap. the class/s i use for the conversiion is on this page

Blackberry WebBitmapField | Coderholic

The only thing i can think of is something on that page in a post thats says put the getBitmap in a while loop until it returns true but don't know if that's a good idea or what the person means properly anyway.

This sounds complicated maybe but the basics of it are mystifying becaus it's already doing it with another variable of the object i'm accessing, just not wiht the image of the product.

Anyone help me please?
Offline  
Old 08-22-2009, 05:02 PM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Model: 8800
Carrier: Orange
Posts: 181
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

In my WebBirtmapField class getBitmap will return null if the image hasn't been downloaded from the web yet (ie. it is still being loaded). You should use a callback to get notified when the image has loaded. See the comments on the post you've linked to for more details.
Offline  
Old 08-22-2009, 05:37 PM   #8 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm really hoping it's that, i'm struggling to understand the concept. If my product class implements webbitmapfield and then includes a callback method in it, the call back method getsinvoked when the webbitmapfield gets the image?? I can then try to assign the recieved image to productImage like this?

public void callback(String data)
{
try
{
byte[] dataArray = data.getBytes();
b = EncodedImage.createEncodedImage(dataArray, 0,
dataArray.length);
//setImage(bitmap);
Log.info("setimagee");
this.productImage = b.getBitmap();
}
catch (final Exception e)
{
Log.info("error at callback" + e);
}

//this.productImage = image.getBitmap();
}

I have been trying this for a bit and getting same results ?? Have I got the concept right for callback?
Offline  
Old 08-22-2009, 07:05 PM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

done it! thank you for your help.

The trick was to change a few constructors to include a product object, add a setImage method and then at callback the product is around to setImage!

Cheers
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.