Search in sources :

Example 66 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.

the class WXRenderStatement method updateAttrs.

/**
   * @see com.taobao.weex.dom.WXDomStatement#updateAttrs(String, JSONObject)
   */
void updateAttrs(String ref, Map<String, Object> attrs) {
    WXComponent component = mRegistry.get(ref);
    if (component == null) {
        return;
    }
    component.updateProperties(attrs);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 67 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class AbstractAddElementAction method addDomInternal.

/**
 * Add DOM node.
 */
protected void addDomInternal(DOMActionContext context, JSONObject dom) {
    if (context.isDestory()) {
        return;
    }
    WXSDKInstance instance = context.getInstance();
    if (instance == null) {
        return;
    }
    String errMsg = getErrorMsg();
    if (dom == null) {
        // instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
        WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(), getErrorCode(), "addDomInternal", errMsg, null);
    }
    // only non-root has parent.
    Stopwatch.tick();
    WXDomObject domObject = WXDomObject.parse(dom, instance, null);
    Stopwatch.split("parseDomObject");
    if (domObject == null || context.getDomByRef(domObject.getRef()) != null) {
        WXLogUtils.e("[DOMActionContextImpl] " + getStatementName() + " error,DOM object is null or already registered!!");
        // instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
        WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(), getErrorCode(), "addDomInternal", errMsg, null);
        return;
    }
    appendDomToTree(context, domObject);
    Stopwatch.split("appendDomToTree");
    int maxDomDep = domObject.traverseTree(context.getAddDOMConsumer(), context.getApplyStyleConsumer());
    if (instance.getMaxDomDeep() < maxDomDep) {
        instance.setMaxDomDeep(maxDomDep);
    }
    Stopwatch.split("traverseTree");
    // Create component in dom thread
    WXComponent component = createComponent(context, domObject);
    if (component == null) {
        // WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(), errCode, "addDomInternal", errMsg, null);
        return;
    }
    Stopwatch.split("createComponent");
    boolean needAddDomInfo = true;
    if (domObject.getType().equals(WXBasicComponentType.CELL_SLOT) && domObject instanceof WXCellDomObject) {
        needAddDomInfo = false;
    }
    if (needAddDomInfo) {
        context.addDomInfo(domObject.getRef(), component);
    }
    context.postRenderTask(this);
    addAnimationForDomTree(context, domObject);
    // instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
    if (WXTracing.isAvailable()) {
        List<Stopwatch.ProcessEvent> events = Stopwatch.getProcessEvents();
        for (Stopwatch.ProcessEvent event : events) {
            submitPerformance(event.fname, "X", context.getInstanceId(), event.duration, event.startMillis, true);
        }
    }
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject) WXComponent(com.taobao.weex.ui.component.WXComponent) Stopwatch(com.taobao.weex.tracing.Stopwatch) WXCellDomObject(com.taobao.weex.dom.WXCellDomObject)

Example 68 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class AddEventAction method executeRender.

@Override
public void executeRender(RenderActionContext context) {
    WXComponent comp = context.getComponent(mRef);
    if (comp != null) {
        // sync dom change to component
        Stopwatch.tick();
        comp.updateDom(mUpdatedDom);
        Stopwatch.split("updateDom");
        comp.addEvent(mEvent);
        Stopwatch.split("addEventToComponent");
        if (WXTracing.isAvailable() && mBeginEvent != null) {
            List<Stopwatch.ProcessEvent> events = Stopwatch.getProcessEvents();
            for (Stopwatch.ProcessEvent event : events) {
                submitPerformance(event.fname, "X", comp.getInstanceId(), event.duration, event.startMillis, true);
            }
        }
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) Stopwatch(com.taobao.weex.tracing.Stopwatch)

Example 69 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class CreateBodyAction method executeRender.

@Override
public void executeRender(RenderActionContext context) {
    WXComponent component = context.getComponent(WXDomObject.ROOT);
    WXSDKInstance instance = context.getInstance();
    if (instance == null || instance.getContext() == null) {
        WXLogUtils.e("instance is null or instance is destroy!");
        mErrMsg.append("instance is null or instance is destroy!");
        return;
    }
    try {
        Stopwatch.tick();
        long start = System.currentTimeMillis();
        component.createView();
        if (WXEnvironment.isApkDebugable()) {
            WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
            submitPerformance("createView", "X", instance.getInstanceId(), Stopwatch.tackAndTick(), start, true);
        }
        start = System.currentTimeMillis();
        component.applyLayoutAndEvent(component);
        if (WXTracing.isAvailable()) {
            submitPerformance("applyLayoutAndEvent", "X", instance.getInstanceId(), Stopwatch.tackAndTick(), start, true);
        }
        start = System.currentTimeMillis();
        component.bindData(component);
        if (WXEnvironment.isApkDebugable()) {
            WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
            submitPerformance("bindData", "X", instance.getInstanceId(), Stopwatch.tack(), start, true);
        }
        if (component instanceof WXScroller) {
            WXScroller scroller = (WXScroller) component;
            if (scroller.getInnerView() instanceof ScrollView) {
                instance.setRootScrollView((ScrollView) scroller.getInnerView());
            }
        }
        instance.onRootCreated(component);
        if (instance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
            instance.onCreateFinish();
        }
        component.mTraceInfo.uiQueueTime = mUIQueueTime;
        component.onRenderFinish(WXComponent.STATE_ALL_FINISH);
    } catch (Exception e) {
        WXLogUtils.e("create body failed.", e);
        mErrMsg.append("create body failed.").append(WXLogUtils.getStackTrace(e)).toString();
    }
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXComponent(com.taobao.weex.ui.component.WXComponent) ScrollView(android.widget.ScrollView) WXScroller(com.taobao.weex.ui.component.WXScroller)

Example 70 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class InvokeMethodAction method executeDom.

@Override
public void executeDom(DOMActionContext context) {
    WXComponent comp = context.getCompByRef(mRef);
    if (comp == null) {
        WXLogUtils.e("DOMAction", "target component not found.");
        return;
    }
    comp.invoke(mMethod, mArgs);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Aggregations

WXComponent (com.taobao.weex.ui.component.WXComponent)101 Point (android.graphics.Point)21 WXDomObject (com.taobao.weex.dom.WXDomObject)20 WXVContainer (com.taobao.weex.ui.component.WXVContainer)19 HashMap (java.util.HashMap)13 View (android.view.View)9 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)9 WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)9 Map (java.util.Map)9 Test (org.junit.Test)9 ArrayMap (android.support.v4.util.ArrayMap)8 RecyclerView (android.support.v7.widget.RecyclerView)8 JSONObject (com.alibaba.fastjson.JSONObject)8 WXSDKInstance (com.taobao.weex.WXSDKInstance)8 ComponentTest (com.taobao.weex.ui.component.ComponentTest)8 WXDivTest (com.taobao.weex.ui.component.WXDivTest)8 Scrollable (com.taobao.weex.ui.component.Scrollable)6 WXBaseRefresh (com.taobao.weex.ui.component.WXBaseRefresh)6 WXHeaderTest (com.taobao.weex.ui.component.WXHeaderTest)6 AppearanceHelper (com.taobao.weex.ui.component.AppearanceHelper)5