Search in sources :

Example 11 with IWXRenderTask

use of com.taobao.weex.ui.IWXRenderTask 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 12 with IWXRenderTask

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

the class WXDomStatement method createFinish.

/**
   * Create a command object for notifying {@link WXRenderManager} that the process of creating
   * given view is finished, and put the command object in the queue.
   */
void createFinish() {
    if (mDestroy) {
        return;
    }
    final WXDomObject root = mRegistry.get(WXDomObject.ROOT);
    mNormalTasks.add(new IWXRenderTask() {

        @Override
        public void execute() {
            mWXRenderManager.createFinish(mInstanceId, (int) root.getLayoutWidth(), (int) root.getLayoutHeight());
        }

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

Aggregations

IWXRenderTask (com.taobao.weex.ui.IWXRenderTask)12 WXSDKInstance (com.taobao.weex.WXSDKInstance)10 WXComponent (com.taobao.weex.ui.component.WXComponent)3 JSONObject (com.alibaba.fastjson.JSONObject)1 WXErrorCode (com.taobao.weex.common.WXErrorCode)1 WXAnimationBean (com.taobao.weex.ui.animation.WXAnimationBean)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1