MultiList icon_URLImage

58 views
Skip to first unread message

Siripé Ibrahim

unread,
Oct 24, 2014, 11:16:37 AM10/24/14
to codenameone...@googlegroups.com
IDE: NetBeans 8.0.1
OS : Win 7
Simulator : Nexus Skin
Device : Galaxy S2
Codename One Version : 1.0.78

I used ImageDownloadService to load online image in multilist (it's worked) for perfomance reason I decide to try URLImage , below my code with update according advise of M. Shai Almog (Thank you to him)

 while (c.next()) 
   {
         hlist = new Hashtable();
         r = c.getRow();

         sb.delete(0, sb.length());
         sb.append("alb").append(r.getInteger(4));
         urlcover = r.getString(10); 
hlist.put("Line1", r.getString(6)); hlist.put("Line2", r.getString(8)); hlist.put("icon", defaultimg); hlist.put("iconName", sb.toString()); hlist.put("icon_URLImage", urlcover); vlist.add(hlist); } mlist.setModel(new Model(vlist)); mlist.setRenderer(createListRenderer()); In createListRenderer my code is : private static MultiButton createRendererMultiButton() { MultiButton b = new MultiButton(); b.setIconName("icon"); b.setNameLine1("Line1"); b.setNameLine2("Line2"); b.setUIID("Label"); return b; } private static ListCellRenderer createListRenderer() { MultiButton sel = createRendererMultiButton(); MultiButton unsel = createRendererMultiButton(); return new GenericListCellRenderer(sel, unsel); }
 I notice a real improvement of perfomance with URLImage, the placeholder is loaded but my online image is still not update in my multilist.

 I don't know what to do to resolve this issue since yesterday.


Shai Almog

unread,
Oct 24, 2014, 8:45:33 PM10/24/14
to codenameone...@googlegroups.com
You need to leave the icon property in the hashtable blank otherwise the URLImage thinks the image was already downloaded.
The placeholder will be used seamlessly.

Siripé Ibrahim

unread,
Oct 25, 2014, 7:13:55 AM10/25/14
to codenameone...@googlegroups.com
Sorry to disturb you again,
I update my code but still not working.
This time there is none image shown on multilist below what I wrote :


 while (c.next())
  {
       ...................
       hlist.put("iconName", sb.toString());
       hlist.put("icon_URLImage", urlcover);
       .............................................
  }
 private static MultiButton createRendererMultiButton(final Image img) {
        MultiButton b = new MultiButton();
        b.setIcon(img);
        b.setIconName("icon");
        b.setNameLine1("Line1");
        b.setNameLine2("Line2");
        b.setUIID("Label");
        return b;
    }
    
    private static ListCellRenderer createListRenderer(final Image img) {
        MultiButton sel = createRendererMultiButton(img);
        MultiButton unsel = createRendererMultiButton(img);
        return new GenericListCellRenderer(sel, unsel);
    }
 

Shai Almog

unread,
Oct 25, 2014, 8:25:51 AM10/25/14
to codenameone...@googlegroups.com
Are you doing this on a List or on a MultiList?
You should not change the renderer on a MultiList, this might have an effect related to this.

Siripé Ibrahim

unread,
Oct 25, 2014, 8:45:29 AM10/25/14
to codenameone...@googlegroups.com
I'm doing this with MultiList in hancoded applications.
Yes I used custom renderer.
I change my code I put  custom renderer in comment, right now it's default renderer but still the same (below code):

                           while (c.next()) 
                            {
                               ...............
                                  hlist.put("iconName", sb.toString());
                                 hlist.put("icon_URLImage", urlcover);
                               .............
                            }
                         // (in comment) mlist.setRenderer(createListRenderer(defaultimg));
                        mlist.setModel(new Model(vlist));

Shai Almog

unread,
Oct 25, 2014, 10:47:26 PM10/25/14
to codenameone...@googlegroups.com
Change it to be list not to remove the renderer since then you would be removing the logic related to the URLImage.

Siripé Ibrahim

unread,
Oct 30, 2014, 10:09:32 AM10/30/14
to codenameone...@googlegroups.com
Hi Shai,

My situation is mystical, I try what you advise me but my situation not change online picture still not loaded

final List list = new List();
while (c.next())
{

   
......
      hlist
.put("iconName", sb.toString());
      hlist
.put("icon_URLImage", urlcover);
   
......
}

list
.setRenderer(createListRenderer());
list
.setModel(new Model(vlist, defaultimg));


 //My GenericListCellRenderer
private static MultiButton createRendererMultiButton() {

       
MultiButton b = new MultiButton();

        b
.setIconName("icon");
        b
.setNameLine1("Line1");
        b
.setNameLine2("Line2");
        b
.setUIID("Label");
       
return b;
   
}

   
   
private static ListCellRenderer createListRenderer() {

       
MultiButton sel = createRendererMultiButton();
       
MultiButton unsel = createRendererMultiButton();
       
return new GenericListCellRenderer(sel, unsel);
   
}





 
//My Model
 
public Object getItemAt(int index) {
       
Hashtable<String, Object> h =  (Hashtable<String, Object>)v.elementAt(index);
        h
.put("icon", defaultIcon);
       
return h;
   
}


When I comment  h.put("icon", defaultIcon); there is no Default Image and my online picture still not loaded

Shai Almog

unread,
Oct 30, 2014, 9:17:16 PM10/30/14
to codenameone...@googlegroups.com
Hi,
do you see requests going out to the image URL in the network monitor?

Siripé Ibrahim

unread,
Dec 9, 2014, 6:31:56 AM12/9/14
to codenameone...@googlegroups.com

Hi Shai,

Hope you are doing well .

Thank you for your kind help and excuse me for long time unavailability due to personal problem.
Regarding your question I don't see any URL loaded in monitor.

But I think it will work with GUI Builder. But Personnally I found my application a little bit fast than application make with GUI Builder.

So do you think generally handcoded application is more light and fast than application make with GUI Builder.

Thanks & Best Regards

Shai Almog

unread,
Dec 9, 2014, 10:00:44 AM12/9/14
to codenameone...@googlegroups.com
Hi,
its a hard nuanced question but generally performance shouldn't be an issue either way. You should be able to handcode everything the GUI builder does.

Siripé Ibrahim

unread,
Dec 10, 2014, 5:19:12 AM12/10/14
to codenameone...@googlegroups.com
Thank you very much, have a good day!
Reply all
Reply to author
Forward
0 new messages