Search in sources :

Example 61 with WXComponent

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

the class WXRenderStatement method addComponent.

/**
   * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int)
   */
void addComponent(WXDomObject dom, String parentRef, int index) {
    WXVContainer parent = (WXVContainer) mRegistry.get(parentRef);
    WXComponent component = generateComponentTree(dom, parent);
    parent.addChild(component, index);
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 62 with WXComponent

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

the class BasicListComponent method onCreateViewHolder.

/**
   * Create an instance of {@link ListBaseViewHolder} for the given viewType (not for the given
   * index). This method will look up for the first component that fits the viewType requirement and
   * doesn't be used. Then create the certain type of view, detach the view f[rom the component.
   *
   * @param parent   the ViewGroup into which the new view will be inserted
   * @param viewType the type of the new view
   * @return the created view holder.
   */
@Override
public ListBaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (mChildren != null) {
        if (mViewTypes == null)
            return createVHForFakeComponent(viewType);
        ArrayList<WXComponent> mTypes = mViewTypes.get(viewType);
        checkRecycledViewPool(viewType);
        if (mTypes == null)
            return createVHForFakeComponent(viewType);
        for (int i = 0; i < mTypes.size(); i++) {
            WXComponent component = mTypes.get(i);
            if (component == null || component.isUsing()) {
                continue;
            }
            if (component.getDomObject() != null && component.getDomObject().isFixed()) {
                return createVHForFakeComponent(viewType);
            } else {
                if (component instanceof WXCell) {
                    if (component.getRealView() != null) {
                        return new ListBaseViewHolder(component, viewType);
                    } else {
                        ((WXCell) component).lazy(false);
                        component.createView();
                        component.applyLayoutAndEvent(component);
                        return new ListBaseViewHolder(component, viewType);
                    }
                } else if (component instanceof WXBaseRefresh) {
                    return createVHForRefreshComponent(viewType);
                } else {
                    WXLogUtils.e(TAG, "List cannot include element except cell、header、fixed、refresh and loading");
                    return createVHForFakeComponent(viewType);
                }
            }
        }
    }
    if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.e(TAG, "Cannot find request viewType: " + viewType);
    }
    return createVHForFakeComponent(viewType);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXBaseRefresh(com.taobao.weex.ui.component.WXBaseRefresh) Point(android.graphics.Point) ListBaseViewHolder(com.taobao.weex.ui.view.listview.adapter.ListBaseViewHolder)

Example 63 with WXComponent

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

the class WXDomStatement method removeEvent.

/**
   * Create a command object for removing the event listener of the corresponding {@link
   * WXDomObject} and put the command event in the queue.
   * @param ref Reference of the dom.
   * @param type the type of the event, this may be a plain event defined in
   * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
   * .weex.ui.view.gesture.WXGestureType}
   */
void removeEvent(final String ref, final String type) {
    if (mDestroy) {
        return;
    }
    WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
    final WXDomObject domObject = mRegistry.get(ref);
    if (domObject == null) {
        if (instance != null) {
            instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEEVENT);
        }
        return;
    }
    domObject.removeEvent(type);
    mNormalTasks.add(new IWXRenderTask() {

        @Override
        public void execute() {
            WXComponent comp = mWXRenderManager.getWXComponent(mInstanceId, ref);
            if (comp != null) {
                //sync dom change to component
                comp.updateDom(domObject);
                mWXRenderManager.removeEvent(mInstanceId, ref, type);
            }
        }

        @Override
        public String toString() {
            return "removeEvent";
        }
    });
    mDirty = true;
    if (instance != null) {
        instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
    }
}
Also used : IWXRenderTask(com.taobao.weex.ui.IWXRenderTask) WXSDKInstance(com.taobao.weex.WXSDKInstance) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 64 with WXComponent

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

the class WXRenderStatement method setPadding.

/**
   * set padding style of View
   */
void setPadding(String ref, Spacing padding, Spacing border) {
    WXComponent component = mRegistry.get(ref);
    if (component == null) {
        return;
    }
    component.setPadding(padding, border);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 65 with WXComponent

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

the class WXRenderStatement method removeEvent.

/**
   * @see WXDomObject#removeEvent(String)
   */
void removeEvent(String ref, String type) {
    WXComponent component = mRegistry.get(ref);
    if (component == null) {
        return;
    }
    component.removeEvent(type);
}
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