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);
}
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);
}
}
}
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);
}
}
}
}
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();
}
}
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);
}
Aggregations