Optimize View creation

This commit is contained in:
estevez 2018-09-28 11:23:48 +03:00
parent 49444ab3df
commit b935a0e372

View File

@ -19,22 +19,15 @@ class UIBuilder {
void build(EntityCollection entitiesCollection) { void build(EntityCollection entitiesCollection) {
_entities = entitiesCollection; _entities = entitiesCollection;
_views.clear(); _views.clear();
_createViewsContainers(entitiesCollection.viewList); _createViews(entitiesCollection.viewList);
} }
void _createViewsContainers(List<String> viewsList) { void _createViews(List<String> viewsList) {
int counter = 0; int counter = 0;
viewsList.forEach((viewId) { viewsList.forEach((viewId) {
counter += 1; counter += 1;
_views[viewId] = View(viewId, counter); View view = View(viewId, counter);
});
//TODO merge this two func into one
_createViews();
}
void _createViews() {
TheLogger.log("Debug","Gethering views");
_views.forEach((viewId, view) { //Each view
try { try {
Entity viewGroupEntity = _entities.get(viewId); Entity viewGroupEntity = _entities.get(viewId);
viewGroupEntity.childEntities.forEach(( viewGroupEntity.childEntities.forEach((
@ -48,6 +41,8 @@ class UIBuilder {
} catch (error) { } catch (error) {
TheLogger.log("Error","Error parsing view: $viewId"); TheLogger.log("Error","Error parsing view: $viewId");
} }
_views[viewId] = view;
}); });
} }