Search in sources :

Example 26 with WXComponent

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);
    }
}
Also used : Rect(android.graphics.Rect) WXComponent(com.taobao.weex.ui.component.WXComponent) HashMap(java.util.HashMap) JSCallback(com.taobao.weex.bridge.JSCallback) SimpleJSCallback(com.taobao.weex.bridge.SimpleJSCallback) WXSDKInstance(com.taobao.weex.WXSDKInstance) SimpleJSCallback(com.taobao.weex.bridge.SimpleJSCallback) HashMap(java.util.HashMap) Map(java.util.Map)

Example 27 with WXComponent

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);
    }
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 28 with WXComponent

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));
        }
    }
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 29 with WXComponent

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);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 30 with WXComponent

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);
    }
}
Also used : WXRecyclerTemplateList(com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList) WXComponent(com.taobao.weex.ui.component.WXComponent) SimpleJSCallback(com.taobao.weex.bridge.SimpleJSCallback)

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