Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
chintan_kanal
Posts: 54
Registered: 03-04-2009

TreeField performance issue

[ Edited ]

Is it normal behavior for TreeField to take long time to add/delete child nodes especially when tree is modified on the fly? I have a requirement wherein user enters some search text based on which the results are displayed in the form of a tree. The search module is optimal and generates results in almost no time, however when I try to make a tree out of it the time consumed rises to the tune of 5-7 seconds for creating/deleting about 60-70 nodes (on simulator and on device its much higher). The time is almost double when the same tree gets constructed when user deletes part of the search text via backspace. Is this expected behavior?

Please check the code posted below I use to update the TreeField.

 

 

public void updateTree(Vector p_searchResultVec) {
m_treeField.deleteAll(); //time consuming when number of nodes in tree is high >=70
Enumeration t_enumElem = p_searchResultVec.elements();
String[] t_childNodes;
int t_nodeID = 0;
m_treeField.setDefaultExpanded(false);
while(t_enumElem.hasMoreElements()) {
Object t_objInfo = t_enumElem.nextElement();
if(t_nodeID == 0) {
t_nodeID = m_treeField.addChildNode(0, t_objInfo); //time consuming
}
else {
t_nodeID = m_treeField.addSiblingNode(t_nodeID, t_objInfo); //time consuming
}
t_childNodes = getChildNodes(t_objInfo.getUID());
for(int i=t_childNodes.length; --i >= 0;) {
m_treeField.addChildNode(t_nodeID, t_childNodes[i]); //time consuming
}
}
}

 

 

 

Please use plain text.