viewspoolmanager.lzx
<library>
<class name="viewspoolmanager">
<attribute name="pools"/>
<method name="getPool" args="parent, className">
if(this.pools == null)
{
this.pools = new Object();
parent["_pools"] = this.pools;
}
var pool = this.pools[className];
if(!pool)
{
pool = new lz.viewspool(parent);
//debug.write(pool);
pool.parentview = parent;
pool.viewclass = className;
this.pools[className] = pool;
}
return pool;
</method>
<method name="reclaimAll">
for( var k in this.pools)
{
this.pools[k].reclaimAll();
}
</method>
</class>
<class name="viewspool" extends="node">
<attribute name="unused" value="$once{[]}"/>
<attribute name="used" value="$once{[]}"/>
<attribute name="parentview" value="$once{null}"/>
<attribute name="viewclass" type="string" value="$once{null}"/>
<method name="getView" args="args">
var marker = null;
if(this.unused.length > 0)
{
marker = this.unused.pop();
}
else
{
marker = new lz[viewclass](parentview, args);
}
this.used.push(marker);
marker.setAttribute('visible', true);
return marker;
</method>
<method name="reclaimAll">
for(var i = 0; i < this.used.length; i++)
{
this.used[i].setAttribute('visible', false);
if(this.used[i]["clear"] != null)
{
this.used[i].clear();
}
}
this.unused = this.unused.concat(this.used);
this.used = [];
</method>
</class>
<class name="viewlistmanager">
<attribute name="pools" value="${new Object()}"/>
<method name="getList" args="parent, className, id">
if(this["pools"] == null)
{
this.pools = new Object();
}
var listName = className;
if(id != null)
{
listName += id;
}
var pool = this.pools[listName];
if(!pool)
{
pool = new lz.viewslist(parent);
pool.parentview = parent;
pool.viewclass = className;
this.pools[listName] = pool;
}
return pool;
</method>
<method name="reclaimAll">
for( var k in this.pools)
{
this.pools[k].reclaimAll();
}
</method>
</class>
<class name="viewslist" extends="node">
<attribute name="vlist" value="$once{[]}"/>
<attribute name="parentview" value="${parent}"/>
<attribute name="viewclass" type="string" value="$once{null}"/>
<method name="getViewAt" args="index, args">
if(this.vlist[index] == null)
{
this.vlist[index] = new lz[viewclass](parentview, args);
}
else
{
this.vlist[index].setAttribute('visible', true);
}
return this.vlist[index];
</method>
<method name="reclaimAll">
for(var i = 0; i < vlist.length; i++)
{
if(vlist[i] != undefined){
vlist[i].setAttribute('visible', false);
//vlist[i].clear();
}
}
</method>
</class>
</library>