Search in sources :

Example 6 with WXCell

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;
}
Also used : WXCell(com.taobao.weex.ui.component.list.WXCell)

Example 7 with WXCell

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;
}
Also used : WXCell(com.taobao.weex.ui.component.list.WXCell)

Example 8 with WXCell

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();
        }
    }));
}
Also used : ListComponentView(com.taobao.weex.ui.component.list.ListComponentView) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) View(android.view.View) WXCell(com.taobao.weex.ui.component.list.WXCell)

Example 9 with WXCell

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();
    }
}
Also used : ViewGroup(android.view.ViewGroup) ListComponentView(com.taobao.weex.ui.component.list.ListComponentView) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) View(android.view.View) WXCell(com.taobao.weex.ui.component.list.WXCell)

Example 10 with WXCell

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();
    }
}
Also used : WXCell(com.taobao.weex.ui.component.list.WXCell)

Aggregations

WXCell (com.taobao.weex.ui.component.list.WXCell)19 WXDomObject (com.taobao.weex.dom.WXDomObject)7 WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)7 JSONObject (com.alibaba.fastjson.JSONObject)6 Point (android.graphics.Point)5 View (android.view.View)5 WXCellDomObject (com.taobao.weex.dom.WXCellDomObject)5 WXRecyclerDomObject (com.taobao.weex.dom.WXRecyclerDomObject)4 WXComponent (com.taobao.weex.ui.component.WXComponent)4 BounceRecyclerView (com.taobao.weex.ui.view.refresh.wrapper.BounceRecyclerView)4 RecyclerView (android.support.v7.widget.RecyclerView)3 WXAttr (com.taobao.weex.dom.WXAttr)3 ListComponentView (com.taobao.weex.ui.component.list.ListComponentView)3 ArrayMap (android.support.v4.util.ArrayMap)2 ViewGroup (android.view.ViewGroup)2 AppearanceHelper (com.taobao.weex.ui.component.AppearanceHelper)2 WXDiv (com.taobao.weex.ui.component.WXDiv)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2