Search in sources :

Example 11 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.

the class AnimationAction method executeDom.

@Override
public void executeDom(DOMActionContext context) {
    try {
        WXDomObject domObject;
        if (!context.isDestory() && animation != null && (domObject = context.getDomByRef(ref)) != null) {
            WXAnimationBean animationBean = JSONObject.toJavaObject(animation, WXAnimationBean.class);
            if (animationBean != null && animationBean.styles != null) {
                int width = (int) domObject.getLayoutWidth();
                int height = (int) domObject.getLayoutHeight();
                animationBean.styles.init(animationBean.styles.transformOrigin, animationBean.styles.transform, width, height, context.getInstance().getInstanceViewPortWidth());
                mAnimationBean = animationBean;
                context.postRenderTask(this);
            }
        }
    } catch (RuntimeException e) {
        WXExceptionUtils.commitCriticalExceptionRT(context.getInstance().getInstanceId(), WXErrorCode.WX_KEY_EXCEPTION_DOM_ANIMATION, "animationAction", WXErrorCode.WX_KEY_EXCEPTION_DOM_ANIMATION.getErrorMsg() + WXLogUtils.getStackTrace(e), null);
        WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e));
    }
}
Also used : WXDomObject(com.taobao.weex.dom.WXDomObject) WXAnimationBean(com.taobao.weex.ui.animation.WXAnimationBean)

Example 12 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.

the class MoveElementAction method executeDom.

@Override
public void executeDom(DOMActionContext context) {
    if (context.isDestory()) {
        return;
    }
    WXSDKInstance instance = context.getInstance();
    WXDomObject domObject = context.getDomByRef(mRef);
    WXDomObject parentObject = context.getDomByRef(mParentRef);
    if (domObject == null || domObject.parent == null || parentObject == null || parentObject.hasNewLayout()) {
        if (instance != null) {
            WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(), WXErrorCode.WX_KEY_EXCEPTION_DOM_MOVE_ELEMENT, "moveElement", WXErrorCode.WX_KEY_EXCEPTION_DOM_MOVE_ELEMENT.getErrorMsg() + "domObject = " + domObject + "domObject.parent= " + domObject.parent + "parentObject = " + parentObject + "parentObject.hasNewLayout() =" + parentObject.hasNewLayout(), null);
        }
        return;
    }
    int index = mIndex;
    if (domObject.parent.equals(parentObject)) {
        if (parentObject.index(domObject) == index) {
            return;
        } else if (domObject.parent.index(domObject) < index) {
            index = index - 1;
        }
    }
    mNewIndex = index;
    domObject.parent.remove(domObject);
    parentObject.add(domObject, mNewIndex);
    context.postRenderTask(this);
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject)

Example 13 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.

the class RemoveElementAction method executeDom.

@Override
public void executeDom(DOMActionContext context) {
    if (context.isDestory()) {
        return;
    }
    WXSDKInstance instance = context.getInstance();
    WXDomObject domObject = context.getDomByRef(mRef);
    if (domObject == null) {
        if (instance != null) {
            // instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
            WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(), WXErrorCode.WX_KEY_EXCEPTION_DOM_REMOVE_ELEMENT, "removeElement", WXErrorCode.WX_KEY_EXCEPTION_DOM_REMOVE_ELEMENT.getErrorMsg() + "domObject is null", null);
        }
        return;
    }
    WXDomObject parent = domObject.parent;
    if (parent == null) {
        if (instance != null) {
            // instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
            WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(), WXErrorCode.WX_KEY_EXCEPTION_DOM_REMOVE_ELEMENT, "removeElement", WXErrorCode.WX_KEY_EXCEPTION_DOM_REMOVE_ELEMENT.getErrorMsg() + "parent is null", null);
        }
        return;
    }
    domObject.traverseTree(context.getRemoveElementConsumer());
    parent.remove(domObject);
    context.unregisterDOMObject(mRef);
    context.postRenderTask(this);
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject)

Example 14 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.

the class UpdateStyleAction method executeDom.

@Override
public void executeDom(DOMActionContext context) {
    if (context.isDestory() || mData == null) {
        return;
    }
    WXSDKInstance instance = context.getInstance();
    WXDomObject domObject = context.getDomByRef(mRef);
    if (domObject == null) {
        if (instance != null) {
            WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(), WXErrorCode.WX_KEY_EXCEPTION_DOM_UPDATE_STYLE, "updateStyle", WXErrorCode.WX_KEY_EXCEPTION_DOM_UPDATE_STYLE.getErrorMsg() + "domObject is null", null);
        }
        return;
    }
    mPadding = domObject.getPadding();
    mBorder = domObject.getBorder();
    if (mData.get(WXDomObject.TRANSFORM) != null || mData.get(WXDomObject.TRANSFORM_ORIGIN) != null) {
        if (domObject.getTransition() == null) {
            Map<String, Object> animationMap = new ArrayMap<>(2);
            animationMap.put(WXDomObject.TRANSFORM, mData.get(WXDomObject.TRANSFORM));
            animationMap.put(WXDomObject.TRANSFORM_ORIGIN, mData.get(WXDomObject.TRANSFORM_ORIGIN));
            context.addAnimationForElement(mRef, animationMap);
        }
    }
    if (!mData.isEmpty()) {
        domObject.updateStyle(mData, mIsCausedByPesudo);
        domObject.applyStyle(mData);
        if (!mData.isEmpty()) {
            context.postRenderTask(this);
        }
    }
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject) ArrayMap(android.support.v4.util.ArrayMap) WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject)

Example 15 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.

the class FontBroadcastReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    String fontFamily = intent.getStringExtra("fontFamily");
    if (!mFontFamily.equals(fontFamily)) {
        return;
    }
    WXTextDomObject wxTextDomObject = wxTextDomObjectRef.get();
    if (wxTextDomObject == null) {
        return;
    }
    if (wxTextDomObject.isDestroy() || wxTextDomObject.getDomContext() == null) {
        return;
    }
    DOMActionContext domActionContext = WXSDKManager.getInstance().getWXDomManager().getDomContext(wxTextDomObject.getDomContext().getInstanceId());
    if (domActionContext == null) {
        return;
    }
    WXDomObject domObject = domActionContext.getDomByRef(wxTextDomObject.getRef());
    if (domObject == null) {
        return;
    }
    domObject.markDirty();
    domActionContext.markDirty();
    WXSDKManager.getInstance().getWXDomManager().sendEmptyMessageDelayed(WXDomHandler.MsgType.WX_DOM_START_BATCH, 2);
    if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d("WXText", "Font family " + fontFamily + " is available");
    }
}
Also used : WXDomObject(com.taobao.weex.dom.WXDomObject) DOMActionContext(com.taobao.weex.dom.DOMActionContext) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject)

Aggregations

WXDomObject (com.taobao.weex.dom.WXDomObject)42 WXSDKInstance (com.taobao.weex.WXSDKInstance)15 WXComponent (com.taobao.weex.ui.component.WXComponent)10 JSONObject (com.alibaba.fastjson.JSONObject)8 WXVContainer (com.taobao.weex.ui.component.WXVContainer)8 Spacing (com.taobao.weex.dom.flex.Spacing)7 WXEvent (com.taobao.weex.dom.WXEvent)6 WXTextDomObject (com.taobao.weex.dom.WXTextDomObject)6 Test (org.junit.Test)6 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)5 Before (org.junit.Before)5 ArrayMap (android.support.v4.util.ArrayMap)4 WXAttr (com.taobao.weex.dom.WXAttr)4 WXDiv (com.taobao.weex.ui.component.WXDiv)4 WXCell (com.taobao.weex.ui.component.list.WXCell)4 HashMap (java.util.HashMap)4 WXStyle (com.taobao.weex.dom.WXStyle)3 FlatGUIContext (com.taobao.weex.ui.flat.FlatGUIContext)3 Map (java.util.Map)3 SpannableString (android.text.SpannableString)2