If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA: eclipse
Desktop OS: windows 7
Simulator : ios 3gs
Device: ----
hey
1) i find jsonParser a bit complicated since i have to CAST values all the time , can u add a JsonMap that extends HashMap and have methods like getAsString(String key), getAsLong(String key), getAsInt(String key), getAsBoolean(String key)
i tried to write something my self , but since "jsonParser.parseJSON" returns an HashMap, i cant CAST it to my map, also trying to overwrite "parseJSON' method is not helping since all variables are private.
i am bit afraid cause next time you will upgrade jsonParser and you will not return "Double" for long values i will be in trouble.......
how can i use a simple map like this ?
or can i use an external json api like Gson ?
public class JsonMap extends HashMap<String, Object>{
public ArrayList<JsonMap> getAsArray(String key) {
return (ArrayList<JsonMap>)get(key);
}
public String getAsString(String key) {
return (String)get(key);
}
public Long getAsLong(String key) {
Object val = get(key);
if(val != null) {
return ((Double)val).longValue();
}
return null;
}
public Integer getAsInt(String key) {
Object val = get(key);
if(val != null) {
return ((Double)val).intValue();
}
return null;
}
public Boolean getAsBoolean(String key) {
Object val = get(key);
if(val != null) {
return Boolean.parseBoolean((String)val);
}
return null;
}
}
2) i have a "Form" with a "List" that is populated by network, the network and population is called only once!
when i am scrolling my "list" up and down the console is printing allot of "Duplicate entry detected"
this is my ListCellRenderer
public class MessageListCellTenderer extends Container implements ListCellRenderer<Message> {
private Container m_userPhoto = new Container() {
protected com.codename1.ui.geom.Dimension calcPreferredSize() {
return new Dimension(50, 50);
};
};
private Label m_from = new Label();
private Label m_message = new Label();
private Object m_photokMaskObj;
public MessageListCellTenderer() {
setLayout(new BorderLayout());
Container textContainer = new Container(new BorderLayout());
textContainer.addComponent(BorderLayout.NORTH, m_from);
textContainer.addComponent(BorderLayout.SOUTH, m_message);
Image opponentPicMaskImage;
try {
opponentPicMaskImage = Image.createImage("message_user_mask.png");
m_photokMaskObj = opponentPicMaskImage.createMask();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
m_userPhoto.setSize(new Dimension(40, 40));
addComponent(BorderLayout.WEST , m_userPhoto);
addComponent(BorderLayout.CENTER, textContainer);
m_userPhoto.getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FIT);
//getStyle().setBorder(Border.)
}
public Component getListCellRendererComponent(List list, Message value, int index, boolean isSelected) {
String userName = value.getUserFromName();
String userImgLink = value.getUserFromPhotoLink();
if(ApplicationData.get().getUid() == value.getUserFromUid()) {
userName = value.getUserToName();
userImgLink = value.getUserToPhotoLink();
}
m_from.setText(userName);
m_message.setText(value.getText());
Network.get().downloadUserImageToStorage(userImgLink, new ActionListener() {
public void actionPerformed(ActionEvent e) {
NetworkEvent evt = (NetworkEvent)e;
Image img = (Image)evt.getMetaData();
img.applyMaskAutoScale(m_photokMaskObj);
m_userPhoto.getStyle().setBgImage(img);
m_userPhoto.setPreferredSize(new Dimension(50, 50));
}
});
return this;
}
public Component getListFocusComponent(List list) {
return this;
}
}
3) how can i make borderBottom to my ListCellRenderer ?
4) the mask is not showing in my ListCellRenderer can u help ?
see attached file, (also making the white transparent not working.....)
thank you
![](https://lh3.googleusercontent.com/-oVrVUtF7yp4/U9udgQ4iKII/AAAAAAAAArg/7llxcpa7FzU/s1600/message_user_mask.png)