11-04-2009 01:50 AM - last edited on 11-04-2009 01:52 AM
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
}
}
}