use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class WXStickyHelper method unbindStickStyle.
public void unbindStickStyle(WXComponent component, Map<String, HashMap<String, WXComponent>> mStickyMap) {
Scrollable scroller = component.getParentScroller();
if (scroller == null) {
return;
}
HashMap<String, WXComponent> stickyMap = mStickyMap.get(scroller.getRef());
if (stickyMap == null) {
return;
}
stickyMap.remove(component.getRef());
}
use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class WXStickyHelper method bindStickStyle.
public void bindStickStyle(WXComponent component, Map<String, HashMap<String, WXComponent>> mStickyMap) {
Scrollable scroller = component.getParentScroller();
if (scroller == null) {
return;
}
HashMap<String, WXComponent> stickyMap = mStickyMap.get(scroller.getRef());
if (stickyMap == null) {
stickyMap = new HashMap<>();
}
if (stickyMap.containsKey(component.getRef())) {
return;
}
stickyMap.put(component.getRef(), component);
mStickyMap.put(scroller.getRef(), stickyMap);
}
use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class WXSDKInstance method setSize.
public void setSize(int width, int height) {
if (width < 0 || height < 0 || isDestroy || !mRendered) {
return;
}
float realWidth = WXViewUtils.getWebPxByWidth(width, getViewPortWidth());
float realHeight = WXViewUtils.getWebPxByWidth(height, getViewPortWidth());
View godView = mRenderContainer;
if (godView != null) {
ViewGroup.LayoutParams layoutParams = godView.getLayoutParams();
if (layoutParams != null) {
if (godView.getWidth() != width || godView.getHeight() != height) {
layoutParams.width = width;
layoutParams.height = height;
godView.setLayoutParams(layoutParams);
}
JSONObject style = new JSONObject();
WXComponent rootComponent = mRootComp;
if (rootComponent == null) {
return;
}
style.put(Constants.Name.DEFAULT_WIDTH, realWidth);
style.put(Constants.Name.DEFAULT_HEIGHT, realHeight);
updateRootComponentStyle(style);
}
}
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class AbstractAddElementAction method generateComponentTree.
protected WXComponent generateComponentTree(DOMActionContext context, WXDomObject dom, WXVContainer parent) {
if (dom == null) {
return null;
}
long startNanos = System.nanoTime();
WXComponent component = WXComponentFactory.newInstance(context.getInstance(), dom, parent);
if (component != null) {
component.mTraceInfo.domThreadStart = dom.mDomThreadTimestamp;
component.mTraceInfo.rootEventId = mTracingEventId;
component.mTraceInfo.domQueueTime = mDomQueueTime;
}
context.registerComponent(dom.getRef(), component);
if (component instanceof WXVContainer) {
WXVContainer parentC = (WXVContainer) component;
int count = dom.childCount();
WXDomObject child = null;
for (int i = 0; i < count; ++i) {
child = dom.getChild(i);
if (child != null) {
WXComponent createdComponent = generateComponentTree(context, child, parentC);
if (createdComponent != null) {
parentC.addChild(createdComponent);
} else {
WXLogUtils.e("[generateComponentTree] " + getStatementName() + " create dom component failed name " + child.getType());
WXExceptionUtils.commitCriticalExceptionRT(context.getInstanceId(), getErrorCode(), "generateComponentTree", " create dom component failed name " + child.getType(), null);
}
}
}
}
if (component != null) {
component.mTraceInfo.domThreadNanos = System.nanoTime() - startNanos;
}
return component;
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class AddElementAction method executeRender.
@Override
public void executeRender(RenderActionContext context) {
WXComponent component = context.getComponent(mRef);
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 {
WXVContainer parent = (WXVContainer) context.getComponent(mParentRef);
if (parent == null || component == null) {
mErrMsg.append("parent == null || component == null").append("parent=" + parent).append("component=" + component);
return;
}
Stopwatch.tick();
parent.addChild(component, mAddIndex);
parent.createChildViewAt(mAddIndex);
Stopwatch.split("createViewTree");
component.applyLayoutAndEvent(component);
Stopwatch.split("applyLayoutAndEvent");
component.bindData(component);
Stopwatch.split("bindData");
if (WXTracing.isAvailable()) {
String instanceId = context.getInstance().getInstanceId();
List<Stopwatch.ProcessEvent> splits = Stopwatch.getProcessEvents();
for (Stopwatch.ProcessEvent event : splits) {
submitPerformance(event.fname, "X", instanceId, event.duration, event.startMillis, true);
}
}
component.mTraceInfo.uiQueueTime = mUIQueueTime;
if (component.isLazy()) {
component.onRenderFinish(WXComponent.STATE_DOM_FINISH);
} else {
component.onRenderFinish(WXComponent.STATE_ALL_FINISH);
}
} catch (Exception e) {
WXLogUtils.e("add component failed.", e);
mErrMsg.append("add component failed.").append(WXLogUtils.getStackTrace(e));
}
instance.onElementChange();
}
Aggregations