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));
}
}
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);
}
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);
}
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);
}
}
}
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");
}
}
Aggregations