Search in sources :

Example 1 with ArrayStack

use of com.taobao.weex.el.parse.ArrayStack in project incubator-weex by apache.

the class FailedCaseTest method testVElseIf0.

public void testVElseIf0() {
    JSONObject data = new JSONObject();
    JSONObject item = new JSONObject();
    item.put("number", 0.0);
    data.put("item", item);
    ArrayStack stack = new ArrayStack();
    stack.push(data);
    Token token = Parser.parse("!(item.number%3 === 0) && (item.number%3 === 1)");
    System.out.println(token.toString() + "  " + token.execute(stack));
    Token if2 = Parser.parse("!(!(item.number%3 === 0) && (item.number%3 === 1))");
    System.out.println(if2 + "   " + if2.execute(stack));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Token(com.taobao.weex.el.parse.Token) ArrayStack(com.taobao.weex.el.parse.ArrayStack)

Example 2 with ArrayStack

use of com.taobao.weex.el.parse.ArrayStack in project incubator-weex by apache.

the class WXRecyclerTemplateList method doRenderTemplate.

/**
 * create code context for render component and do render
 */
private List<WXComponent> doRenderTemplate(WXCell cell, int position) {
    this.cellRenderContext.clear();
    Object item = cellDataManager.listData.get(position);
    CellRenderState cellRenderState = cellDataManager.getRenderState(position);
    cellRenderContext.renderState = cellRenderState;
    cellRenderContext.templateList = this;
    cellRenderContext.position = position;
    ArrayStack stack = cellRenderContext.stack;
    Map map = cellRenderContext.map;
    if (cellDataManager.listData != null) {
        stack.push(map);
        map.put(listDataKey, cellDataManager.listData);
        if (!TextUtils.isEmpty(listDataIndexKey)) {
            map.put(listDataIndexKey, new PositionRef(cellRenderState));
        }
        if (!TextUtils.isEmpty(listDataItemKey)) {
            map.put(listDataItemKey, item);
        } else {
            stack.push(item);
        }
    }
    if (cellRenderState.itemId <= 0) {
        getItemId(position);
    }
    List<WXComponent> updates = Statements.doRender(cell, this.cellRenderContext);
    if (cellRenderState.isDirty()) {
        cellRenderState.resetDirty();
    }
    return updates;
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject) WXCellDomObject(com.taobao.weex.dom.WXCellDomObject) WXRecyclerDomObject(com.taobao.weex.dom.WXRecyclerDomObject) ArrayStack(com.taobao.weex.el.parse.ArrayStack) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 3 with ArrayStack

use of com.taobao.weex.el.parse.ArrayStack in project incubator-weex by apache.

the class WXRecyclerTemplateList method copyStack.

public ArrayStack copyStack(CellRenderContext context, ArrayStack stack) {
    ArrayStack onceStack = new ArrayStack();
    for (int index = 0; index < stack.size(); index++) {
        Object value = stack.get(index);
        if (value instanceof Map) {
            value = new HashMap((Map) value);
        }
        onceStack.push(value);
    }
    return onceStack;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject) WXCellDomObject(com.taobao.weex.dom.WXCellDomObject) WXRecyclerDomObject(com.taobao.weex.dom.WXRecyclerDomObject) ArrayStack(com.taobao.weex.el.parse.ArrayStack) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Point(android.graphics.Point)

Example 4 with ArrayStack

use of com.taobao.weex.el.parse.ArrayStack in project incubator-weex by apache.

the class StatementTest method createContext.

private CellRenderContext createContext(int count) {
    JSONObject data = new JSONObject();
    data.put("item", new JSONObject());
    data.getJSONObject("item").put("name", "hello world");
    List<String> datas = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        datas.add("hello" + count);
    }
    data.getJSONObject("item").put("list", datas);
    data.put("dataList", datas);
    ArrayStack context = new ArrayStack();
    context.push(data);
    CellRenderContext cellRenderContext = new CellRenderContext();
    cellRenderContext.stack = context;
    return cellRenderContext;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ArrayList(java.util.ArrayList) CellRenderContext(com.taobao.weex.ui.component.list.template.CellRenderContext) ArrayStack(com.taobao.weex.el.parse.ArrayStack)

Example 5 with ArrayStack

use of com.taobao.weex.el.parse.ArrayStack in project incubator-weex by apache.

the class IfStatementTest method createContext.

private ArrayStack createContext() {
    JSONObject data = new JSONObject();
    data.put("item", new JSONObject());
    data.put("index", 20);
    data.put("source", true);
    data.getJSONObject("item").put("name", "hello world");
    ArrayStack context = new ArrayStack();
    context.push(data);
    return context;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ArrayStack(com.taobao.weex.el.parse.ArrayStack)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)8 ArrayStack (com.taobao.weex.el.parse.ArrayStack)8 ArrayMap (android.support.v4.util.ArrayMap)4 WXDomObject (com.taobao.weex.dom.WXDomObject)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 WXAttr (com.taobao.weex.dom.WXAttr)2 WXCellDomObject (com.taobao.weex.dom.WXCellDomObject)2 WXRecyclerDomObject (com.taobao.weex.dom.WXRecyclerDomObject)2 WXComponent (com.taobao.weex.ui.component.WXComponent)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Point (android.graphics.Point)1 EventResult (com.taobao.weex.bridge.EventResult)1 WXEvent (com.taobao.weex.dom.WXEvent)1 WXStyle (com.taobao.weex.dom.WXStyle)1 Token (com.taobao.weex.el.parse.Token)1 WXImage (com.taobao.weex.ui.component.WXImage)1 WXVContainer (com.taobao.weex.ui.component.WXVContainer)1 WXCell (com.taobao.weex.ui.component.list.WXCell)1 CellRenderContext (com.taobao.weex.ui.component.list.template.CellRenderContext)1