Horizontal List with images inside (Icon of label)

150 views
Skip to first unread message

wicky...@gmail.com

unread,
Jan 30, 2014, 1:55:38 PM1/30/14
to codenameone...@googlegroups.com
Hi,

I guess this is the last question of the day, been trying to figure it out for a while now.
I have a horizontal list, where rendered in a custom class.......It shows perfectly fine in the simulator. However when i send to compile and install on the real phone, The list does not show.

I am using it as an image gallery, hence the list. and it works great in the emulator.
Phone, testing on Samsung GX II ... android, old version 2.3.6

Code as below in the renderer.

 Container c = new Container(new BorderLayout());
        c
.setUIID("ShopGalleryRenderer");
        c
.setName("GalleryItem");
         
Label icon = new Label();
         icon
.setName("icon");
         icon
.setUIID("ShopGalleryPic");
         c
.addComponent(BorderLayout.CENTER,icon);
       
return c;

And outside, the list code as below :

               
  com.codename1.ui.List _imgList = new com.codename1.ui.List();
                 _imgList
.setOrientation(List.HORIZONTAL);
                 
                 _imgList
.setUIID("ShopGalleryList");
                 _imgList
.setModel(_galleryImages);
                 
final String shopid = (String)cafeDetail.get("Id");
                 
                 
               
while(_galleryEnum.hasMoreElements())
               
{
                   
String key = (String)_galleryEnum.nextElement();
                   
Hashtable _object = (Hashtable)galleryDetail.get(key);
                    java
.util.Hashtable _map = new java.util.Hashtable();
                   
String imgname = (String)_object.get("Title");
                    _map
.put("Picture", imgname);
                    _map
.put("Shopid", shopid);
                   _galleryImages
.addItem(_map);
               
}
               
                 
//_gallery.setImageList(_galleryImages);
                _imgList
.setRenderer(new ShopGalleryRenderer(_resources));
               
this.addComponent(_imgList);


"this" equals to a BoxLayout container on the Y axis.


Please advise is it just for the version, which i suspect it is. because in the simulator it works fine as per screenshot.


Regards,
Wick

Shai Almog

unread,
Jan 31, 2014, 2:09:47 AM1/31/14
to codenameone...@googlegroups.com, wicky...@gmail.com
Hi,
usually these things happen because of race conditions or missing data that prompts incorrect size calculations.
I suggest enabling the edt violation detection tool in the simulator just to make sure you didn't do something incorrect. Also I suggest setting the lists rendering prototype to something that will occupy the size taken up by the list. This will guarantee the list will be sized correctly by the layout.

wicky...@gmail.com

unread,
Jan 31, 2014, 9:41:00 AM1/31/14
to codenameone...@googlegroups.com, wicky...@gmail.com
Hi Shai,

I have tried to debug the EDT,everything looks to be normal, no exception was thrown. Can you elaborate on race conditions? I think it is because of some revalidate needed by the container of the list? maybe.
I also tried putting placeholder images, those show fine, but it does not refresh with the new images loaded from imagedownloadservice. here is the rest of the code in the render function.
Remember, it works correctly on simulator but not after built. This also works fine n correct on the first form, on the phone. I removed the scale of dimensions for now.
And have a container.revalidate() on the most outside container.

Any clues? Let me know if u need anymore info.


public Component getCellRendererComponent(Component list, Object model, Object value, int index, boolean isSelected) {
       
       
Hashtable v = (Hashtable) value;
       
String shopid = (String) v.get("Shopid");
       
String imagename = (String) v.get("Picture");
       
Image im = (Image)v.get("pic");
       
       
if(im == null && shopid != null && v.get("fetching") == null){
            v
.put("fetching", Boolean.TRUE);
           
try {
                   
CoffeeShopAccess.getInstance().getPicture(shopid,String.valueOf(index),imagename,list, index, "pic", null, true);
           
} catch (Exception ex) {
                    ex
.printStackTrace();
           
}
       
}else{
           
if(im!=null)
           
{
               
                v
.put("icon", im);
           
}
       
}
       
return super.getCellRendererComponent(list, model, value, index, isSelected);
   
}





Also, I was trying to accomplish this by ImageViewer, but in ImageViewer i cannot populate the images using ImageDownloadService as it only supports components with List type or Containter List type.
Any ways to work around it? I tried putting labels, calling Actioncallback but the ImageViewer although after adding images to its model, does not show downloaded images.

Anyways thats another issue, which was facing before i chose this way.

wicky...@gmail.com

unread,
Jan 31, 2014, 10:38:13 AM1/31/14
to codenameone...@googlegroups.com, wicky...@gmail.com
Hi,

I have exhausted my means of switching the code around, no luck.
The placeholder image shows correctly ...... but not the actual downloaded image (which works in emulator without any EDT errors) ... and have removed the dimensions.

Please advise :)
Regards,
Wick

Steve Hannah

unread,
Jan 31, 2014, 11:29:54 AM1/31/14
to codenameone...@googlegroups.com, wicky...@gmail.com
Have you tried connecting your device to ADT so you can see the debug log?  Maybe there is an exception thrown or some errors logged that might shed some light.

Steve


--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/4d3a7ba1-8716-4d89-8ed1-96030d1f5ff5%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Steve Hannah
Web Lite Solutions Corp.

wicky...@gmail.com

unread,
Feb 4, 2014, 2:37:43 PM2/4/14
to codenameone...@googlegroups.com, wicky...@gmail.com
Hi,

I have successfully debug the phone device using the ADT (android development toolkit) ....
To do so i had to install the tool-kit, and go to the package-tools folder under the android sdk installed folder,

used commands "adb logcat > logcat.txt -d" to dump the logs into the file from the device. I got the log dump and found out that it is actually my stupid mistake,
The image path was wrong in the URL that is sent to the imagedownloadservice.

I corrected it, now it works like a charm. I decided to switch to use ImageViewer by setting the datachanged event to the list and in there add the data to the model, there is actually a good sample code in this discussion just search for "ImageViewer Imagedownloadservice."

What still gives me the surprise is, how can the Emulator load the right image if the path is wrong. Its like it is running on a ghost protocol.

So hail to that, and thankz for your help....finally solved.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.

ayoola ajebeku

unread,
Feb 5, 2014, 4:40:45 AM2/5/14
to codenameone...@googlegroups.com, wicky...@gmail.com
"What still gives me the surprise is, how can the Emulator load the right image if the path is wrong. Its like it is running on a ghost protocol."

- This happens if you specify the correct url at first and maybe change it along the way; ImageDownloadService must have cached the image when the url was correct, hence the right image.
- Another reason could be from the backslash - if the wrong url was from using backslash instead of forward slash, the emulator might correct that, but that's not the same with the phones.

Reply all
Reply to author
Forward
0 new messages