Skip to first unread message

Paweł WIchrowski

unread,
Jan 29, 2014, 1:57:21 PM1/29/14
to codenameone...@googlegroups.com
Hi,
I have some questions about using lists in codename. I have List with my own ListModel (which implements com.codename1.ui.list.ListModel) and with own renderer (which extends Container and implements ListCellRenderer). Now one of the elements in that list is an button. It works fine but it doesn't change style when clicked. I should also mention that I didn't override any style it is all derived from default one. So my questions are:
1. How could I make that button change style when clicked? I tried to set its UIID but it seems it still do not work and also it leads me to my next question:
2. When I set UIID on component it seems that I have to define all of its style from scratch. Is there a way to change let say only foreground color and inherit every other aspect of the style from default style?
3. My list will be pretty big so I do not want to load all of its elements first time. Right now my whole list is saved to the FileSystemStorage via protostuff method ProtostuffIOUtil.writeListTo() and load via ProtostuffIOUtil.parseListFrom. So first of all I do not want to read and write all of my list every time from/to FileSystemStorage. Next if I have some reasonable small portion of list I would like to auto fetch it while let say user will scroll it. Is this possible with some codename one component or do I have to write it from scratch. Or maybe there is some better way to achieve  this?
4. My list model among simple fields will contain images and videos . So also I would like to load them only when user click on the item and go to the details view. Is there some way to lazy load elements like that. What would be Your recomendation?
5. Another thing is that my list will contain some sensitive data. So I would like to encode it before saving to FileSystemStorage and decode it only while it is used (same thing like in previous question it could be lazy loaded and decoded only when user really need it and encode back when user go back to the list view). BouncyCastle is my library of choice here but what would be the best storage type for encrypted data?

I know these are big questions but I really want to get some tips and ideas how it could be implemented. 

Best regards.

Bryan Buchanan

unread,
Jan 29, 2014, 7:14:46 PM1/29/14
to codenameone...@googlegroups.com
My guess is it will be impossible to change the rendering of a button. A list is a rubber stamp for each row. Did you see Shai's recent blog posting on lists ?

Steve Hannah

unread,
Jan 29, 2014, 7:46:19 PM1/29/14
to codenameone...@googlegroups.com
I think you can achieve close to what you want if you focus on the ListModel.  It is true that each cell of the list is just a rubber stamp (so it's not live and interactive like normal components), but you can detect touch events on the list itself, and then update the list model (i.e. mark the appropriate index of the list model as changed so that the renderer will re-render your cell).    This is a little bit complex because you would have to take the touch event and figure out if it was in the location of your cell and button... but it is possible.

If you don't need to know exactly where the cell was touched, you could just rely on the list's action listener notifications to tell you when a cell is selected, then update your list model accordingly.

Steve

Shai Almog

unread,
Jan 30, 2014, 1:57:22 AM1/30/14
to codenameone...@googlegroups.com
The post mentioned by Bryan: http://www.codenameone.com/3/post/2013/12/deeper-in-the-renderer.html

Steve is correct but generally list was designed for high performance large "lists" less for individual cell interaction.

2. Sure
getSelectedStyle().setFgColor(...);
getUnselectedStyle
().setFgColor(...);
The following call to setUIID will reset to defaults.

4/3. The list model is designed for lazy loading, you only need to load the data when getItem is invoked. Notice that getItem should be very fast so you can return dummy data, load asynchronously and fire a data change event see  http://code.google.com/p/codenameone/source/browse/trunk/CodenameOne/src/com/codename1/cloud/CloudListModel.java
5. Use storage, it should be mostly private but obviously nothing is secure so bouncy castle is essential.
Reply all
Reply to author
Forward
0 new messages