use of com.taobao.weex.ui.component.list.WXCell in project incubator-weex by apache.
the class WXRecyclerTemplateList method getCellTemplateFromCache.
/**
* @param template template name
* get cell template component from cache, if cell component not load
* start load cell template
*/
private WXCell getCellTemplateFromCache(final String template) {
TemplateCache cache = mTemplatesCache.get(template);
WXCell component = null;
if (cache != null && cache.cells != null && cache.cells.size() > 0) {
component = cache.cells.poll();
}
if (cache == null || !cache.isLoadIng) {
if (cache == null) {
cache = new TemplateCache();
mTemplatesCache.put(template, cache);
}
cache.isLoadIng = true;
WXCell source = mTemplateSources.get(template);
if (source != null) {
boolean allowPreload = WXUtils.getBoolean(source.getDomObject().getAttrs().get("preload"), true);
if (allowPreload) {
AsyncCellLoadTask asyncCellLoadTask = new AsyncCellLoadTask(template, source, this);
asyncCellLoadTask.startTask();
}
}
}
return component;
}
use of com.taobao.weex.ui.component.list.WXCell in project incubator-weex by apache.
the class AsyncCellLoadTask method doInBackground.
/**
* async template cell component copy in background
*/
@Override
protected Void doInBackground(Void... params) {
TemplateCache cellCache = templateList.getTemplatesCache().get(template);
if (cellCache == null || cellCache.cells == null) {
return null;
}
while (cellCache.cells.size() < templateList.getTemplateCacheSize()) {
long start = System.currentTimeMillis();
WXCell component = (WXCell) templateList.copyComponentFromSourceCell(source);
if (WXEnvironment.isOpenDebugLog() && WXRecyclerTemplateList.ENABLE_TRACE_LOG) {
WXLogUtils.d(WXRecyclerTemplateList.TAG, " AsyncCellLoadTask load " + template + " used " + (System.currentTimeMillis() - start));
}
if (component == null) {
return null;
}
if (isDestory()) {
return null;
}
cellCache.cells.add(component);
}
return null;
}
use of com.taobao.weex.ui.component.list.WXCell in project weex-example by KalicyZhou.
the class BounceRecyclerView method removeSticky.
/**
* remove top stickyView
* @param component
*/
private void removeSticky(WXComponent component) {
final WXCell headComponent = headComponentStack.pop();
if (!component.getRef().equals(headComponent.getRef())) {
headComponentStack.push(headComponent);
return;
}
final View headerView = headerViewStack.pop();
post(WXThread.secure(new Runnable() {
@Override
public void run() {
removeView(headerView);
headComponent.recoverySticky();
}
}));
}
use of com.taobao.weex.ui.component.list.WXCell in project weex-example by KalicyZhou.
the class BounceRecyclerView method clearSticky.
/**
* Clear All Sticky of stack
*/
public void clearSticky() {
int size = headComponentStack.size();
while (size > 0 && headerViewStack.size() == size) {
WXCell headComponent = headComponentStack.pop();
View headerView = headerViewStack.pop();
((ViewGroup) getParent()).removeView(headerView);
headComponent.recoverySticky();
}
}
use of com.taobao.weex.ui.component.list.WXCell in project weex-example by KalicyZhou.
the class BounceRecyclerView method notifyStickyShow.
/**
* @param component
*/
public void notifyStickyShow(WXCell component) {
if (component == null)
return;
if (!headComponentStack.isEmpty()) {
WXCell oldCom = headComponentStack.pop();
if (!oldCom.getRef().equals(component.getRef())) {
headComponentStack.push(oldCom);
headComponentStack.push(component);
showSticky();
} else {
headComponentStack.push(oldCom);
return;
}
} else {
headComponentStack.push(component);
showSticky();
}
}
Aggregations