use of com.taobao.weex.dom.DOMActionContext 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");
}
}
use of com.taobao.weex.dom.DOMActionContext in project incubator-weex by apache.
the class WXTransition method doLayoutPropertyValuesHolderAnimation.
private void doLayoutPropertyValuesHolderAnimation(PropertyValuesHolder[] holders) {
layoutValueAnimator = ValueAnimator.ofPropertyValuesHolder(holders);
layoutValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
PropertyValuesHolder[] holders = animation.getValues();
for (PropertyValuesHolder holder : holders) {
String property = holder.getPropertyName();
updateShadowLayoutPropertyByName(domObject, property, (Float) animation.getAnimatedValue(property));
}
DOMActionContext domActionContext = WXSDKManager.getInstance().getWXDomManager().getDomContext(domObject.getDomContext().getInstanceId());
if (domActionContext == null) {
return;
}
domActionContext.markDirty();
WXSDKManager.getInstance().getWXDomManager().sendEmptyMessageDelayed(WXDomHandler.MsgType.WX_DOM_TRANSITION_BATCH, 0);
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("WXTransition send layout batch msg");
}
}
});
layoutValueAnimator.addListener(new AnimatorListenerAdapter() {
boolean hasCancel = false;
@Override
public void onAnimationCancel(Animator animation) {
super.onAnimationCancel(animation);
hasCancel = true;
}
@Override
public void onAnimationEnd(Animator animation) {
if (hasCancel) {
return;
}
super.onAnimationEnd(animation);
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("WXTransition layout onTransitionAnimationEnd " + domObject.getRef());
}
WXTransition.this.onTransitionAnimationEnd();
}
});
if (interpolator != null) {
layoutValueAnimator.setInterpolator(interpolator);
}
layoutValueAnimator.setStartDelay((long) (delay));
layoutValueAnimator.setDuration((long) (duration));
layoutValueAnimator.start();
}
use of com.taobao.weex.dom.DOMActionContext in project incubator-weex by apache.
the class WXTransition method asynchronouslyUpdateLayout.
@SuppressWarnings("unused")
public static void asynchronouslyUpdateLayout(WXComponent component, String propertyName, float propertyValue) {
if (component == null || TextUtils.isEmpty(propertyName)) {
return;
}
String instanceId = component.getInstanceId();
DOMActionContext domActionContext = WXSDKManager.getInstance().getWXDomManager().getDomContext(instanceId);
if (domActionContext == null) {
return;
}
WXDomObject domObject = domActionContext.getDomByRef(component.getRef());
if (domObject == null || TextUtils.isEmpty(instanceId)) {
return;
}
updateShadowLayoutPropertyByName(domObject, propertyName, propertyValue);
domActionContext.markDirty();
WXSDKManager.getInstance().getWXDomManager().sendEmptyMessageDelayed(WXDomHandler.MsgType.WX_DOM_TRANSITION_BATCH, 0);
}
use of com.taobao.weex.dom.DOMActionContext in project incubator-weex by apache.
the class ComponentUtils method buildTree.
/**
* build component tree and dom tree for template list
*/
public static final synchronized WXComponent buildTree(WXDomObject domObject, WXVContainer parent) {
DOMActionContext domActionContext = WXSDKManager.getInstance().getWXDomManager().getDomContext(parent.getInstanceId());
if (domActionContext == null) {
return null;
}
DomTreeBuilder builder = new DomTreeBuilder();
domObject.traverseTree(domActionContext.getAddDOMConsumer(), domActionContext.getApplyStyleConsumer());
return builder.buildComponentTree(domActionContext, domObject, parent);
}
Aggregations