use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class GetComponentRectAction method executeRender.
@Override
public void executeRender(RenderActionContext context) {
WXSDKInstance instance = context.getInstance();
JSCallback jsCallback = new SimpleJSCallback(context.getInstance().getInstanceId(), mCallback);
if (instance == null || instance.isDestroy()) {
// do nothing
} else if (TextUtils.isEmpty(mRef)) {
Map<String, Object> options = new HashMap<>();
options.put("result", false);
options.put("errMsg", "Illegal parameter");
jsCallback.invoke(options);
} else if ("viewport".equalsIgnoreCase(mRef)) {
callbackViewport(context, jsCallback);
} else {
WXComponent component = context.getComponent(mRef);
Map<String, Object> options = new HashMap<>();
if (component != null) {
int viewPort = instance.getInstanceViewPortWidth();
Map<String, Float> size = new HashMap<>();
Rect sizes = component.getComponentSize();
size.put("width", getWebPxValue(sizes.width(), viewPort));
size.put("height", getWebPxValue(sizes.height(), viewPort));
size.put("bottom", getWebPxValue(sizes.bottom, viewPort));
size.put("left", getWebPxValue(sizes.left, viewPort));
size.put("right", getWebPxValue(sizes.right, viewPort));
size.put("top", getWebPxValue(sizes.top, viewPort));
options.put("size", size);
options.put("result", true);
} else {
options.put("errMsg", "Component does not exist");
}
jsCallback.invoke(options);
}
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class MoveElementAction method executeRender.
@Override
public void executeRender(RenderActionContext context) {
WXComponent component = context.getComponent(mRef);
WXComponent newParent = context.getComponent(mParentRef);
if (component == null || component.getParent() == null || newParent == null || !(newParent instanceof WXVContainer)) {
return;
}
WXVContainer oldParent = component.getParent();
oldParent.remove(component, false);
((WXVContainer) newParent).addChild(component, mNewIndex);
if (!component.isVirtualComponent()) {
((WXVContainer) newParent).addSubView(component.getHostView(), mNewIndex);
}
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class RemoveElementAction method clearRegistryForComponent.
private void clearRegistryForComponent(RenderActionContext context, WXComponent component) {
WXComponent removedComponent = context.unregisterComponent(component.getDomObject().getRef());
if (removedComponent != null) {
removedComponent.removeAllEvent();
removedComponent.removeStickyStyle();
}
if (component instanceof WXVContainer) {
WXVContainer container = (WXVContainer) component;
int count = container.childCount();
for (int i = count - 1; i >= 0; --i) {
clearRegistryForComponent(context, container.getChild(i));
}
}
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class UpdateAttributeAction method executeRender.
@Override
public void executeRender(RenderActionContext context) {
WXComponent comp = context.getComponent(mRef);
if (comp == null) {
return;
}
comp.updateProperties(mData);
}
use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.
the class UpdateComponentDataAction method executeRender.
@Override
public void executeRender(RenderActionContext context) {
String ref = CellDataManager.getListRef(virtualComponentId);
if (TextUtils.isEmpty(ref)) {
WXLogUtils.e("wrong virtualComponentId split error " + virtualComponentId);
return;
}
WXComponent component = context.getComponent(ref);
if (component instanceof WXRecyclerTemplateList) {
WXRecyclerTemplateList templateList = (WXRecyclerTemplateList) component;
templateList.getCellDataManager().updateVirtualComponentData(virtualComponentId, data);
templateList.notifyUpdateList();
SimpleJSCallback jsCallback = new SimpleJSCallback(component.getInstanceId(), callback);
jsCallback.invoke(true);
} else {
WXLogUtils.e("recycler-list wrong virtualComponentId " + virtualComponentId);
}
}
Aggregations