Search in sources :

Example 1 with DOMActionContext

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");
    }
}
Also used : WXDomObject(com.taobao.weex.dom.WXDomObject) DOMActionContext(com.taobao.weex.dom.DOMActionContext) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject)

Example 2 with DOMActionContext

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();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) DOMActionContext(com.taobao.weex.dom.DOMActionContext) PropertyValuesHolder(android.animation.PropertyValuesHolder) ValueAnimator(android.animation.ValueAnimator)

Example 3 with DOMActionContext

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);
}
Also used : WXDomObject(com.taobao.weex.dom.WXDomObject) DOMActionContext(com.taobao.weex.dom.DOMActionContext)

Example 4 with DOMActionContext

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);
}
Also used : DOMActionContext(com.taobao.weex.dom.DOMActionContext)

Aggregations

DOMActionContext (com.taobao.weex.dom.DOMActionContext)4 WXDomObject (com.taobao.weex.dom.WXDomObject)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 PropertyValuesHolder (android.animation.PropertyValuesHolder)1 ValueAnimator (android.animation.ValueAnimator)1 WXTextDomObject (com.taobao.weex.dom.WXTextDomObject)1