Search in sources :

Example 31 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class UpdateStyleAction method executeRender.

@Override
public void executeRender(RenderActionContext context) {
    WXComponent component = context.getComponent(mRef);
    if (component == null) {
        return;
    }
    component.updateProperties(mData);
    if (mData.containsKey(Constants.Name.PADDING) || mData.containsKey(Constants.Name.PADDING_TOP) || mData.containsKey(Constants.Name.PADDING_LEFT) || mData.containsKey(Constants.Name.PADDING_RIGHT) || mData.containsKey(Constants.Name.PADDING_BOTTOM) || mData.containsKey(Constants.Name.BORDER_WIDTH)) {
        Spacing padding = mPadding;
        Spacing border = mBorder;
        component.setPadding(padding, border);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) Spacing(com.taobao.weex.dom.flex.Spacing)

Example 32 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class WXTransition method doTransitionAnimation.

/**
 * doTransitionAnimation include transform and layout animation.
 * 1. put pre transition updates from target style to dom style
 * 2. do transform animation and layout animation
 */
private void doTransitionAnimation(final int token) {
    final View taregtView = getTargetView();
    if (taregtView == null) {
        return;
    }
    if (targetStyles.size() > 0) {
        for (String property : properties) {
            if (!(LAYOUT_PROPERTIES.contains(property) || TRANSFORM_PROPERTIES.contains(property))) {
                continue;
            }
            if (layoutPendingUpdates.containsKey(property)) {
                continue;
            }
            if (transformPendingUpdates.containsKey(property)) {
                continue;
            }
            synchronized (targetStyles) {
                if (targetStyles.containsKey(property)) {
                    // reset pre transition style
                    Object targetValue = targetStyles.remove(property);
                    domObject.getStyles().put(property, targetValue);
                    WXComponent component = getComponent();
                    if (component != null && component.getDomObject() != null) {
                        component.getDomObject().getStyles().put(property, targetValue);
                    }
                }
            }
        }
    }
    if (transitionEndEvent != null) {
        taregtView.removeCallbacks(transitionEndEvent);
    }
    if (transitionEndEvent == null && duration > Float.MIN_NORMAL) {
        transitionEndEvent = new Runnable() {

            @Override
            public void run() {
                transitionEndEvent = null;
                if (duration < Float.MIN_NORMAL) {
                    return;
                }
                WXComponent component = getComponent();
                if (component != null && domObject.getEvents().contains(Constants.Event.ON_TRANSITION_END)) {
                    component.fireEvent(Constants.Event.ON_TRANSITION_END);
                }
            }
        };
    }
    if (transformAnimationRunnable != null) {
        taregtView.removeCallbacks(transformAnimationRunnable);
    }
    transformAnimationRunnable = new Runnable() {

        @Override
        public void run() {
            synchronized (lockToken) {
                if (token == lockToken.get()) {
                    doPendingTransformAnimation(token);
                }
            }
        }
    };
    taregtView.post(transformAnimationRunnable);
    doPendingLayoutAnimation();
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXDomObject(com.taobao.weex.dom.WXDomObject) View(android.view.View)

Example 33 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class WXTransition method onTransitionAnimationEnd.

private synchronized void onTransitionAnimationEnd() {
    if (duration > 0) {
        if (transitionEndEvent != null) {
            View view = getTargetView();
            if (view != null && transitionEndEvent != null) {
                view.post(transitionEndEvent);
            }
            transitionEndEvent = null;
        }
    }
    synchronized (targetStyles) {
        if (targetStyles.size() > 0) {
            WXComponent component = getComponent();
            for (String property : properties) {
                if (targetStyles.containsKey(property)) {
                    Object targetValue = targetStyles.remove(property);
                    domObject.getStyles().put(property, targetValue);
                    if (component != null && component.getDomObject() != null) {
                        component.getDomObject().getStyles().put(property, targetValue);
                    }
                }
            }
            targetStyles.clear();
        }
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXDomObject(com.taobao.weex.dom.WXDomObject) View(android.view.View)

Example 34 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class RenderActionContextImpl method setExtra.

/**
 * set extra information of View
 */
void setExtra(String ref, Object extra) {
    WXComponent component = mRegistry.get(ref);
    if (component == null) {
        return;
    }
    component.updateExtra(extra);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 35 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class SimpleComponentHolder method createInstance.

@Override
public synchronized WXComponent createInstance(WXSDKInstance instance, WXDomObject node, WXVContainer parent) throws IllegalAccessException, InvocationTargetException, InstantiationException {
    WXComponent component = mCreator.createInstance(instance, node, parent);
    component.bindHolder(this);
    return component;
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Aggregations

WXComponent (com.taobao.weex.ui.component.WXComponent)101 Point (android.graphics.Point)21 WXDomObject (com.taobao.weex.dom.WXDomObject)20 WXVContainer (com.taobao.weex.ui.component.WXVContainer)19 HashMap (java.util.HashMap)13 View (android.view.View)9 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)9 WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)9 Map (java.util.Map)9 Test (org.junit.Test)9 ArrayMap (android.support.v4.util.ArrayMap)8 RecyclerView (android.support.v7.widget.RecyclerView)8 JSONObject (com.alibaba.fastjson.JSONObject)8 WXSDKInstance (com.taobao.weex.WXSDKInstance)8 ComponentTest (com.taobao.weex.ui.component.ComponentTest)8 WXDivTest (com.taobao.weex.ui.component.WXDivTest)8 Scrollable (com.taobao.weex.ui.component.Scrollable)6 WXBaseRefresh (com.taobao.weex.ui.component.WXBaseRefresh)6 WXHeaderTest (com.taobao.weex.ui.component.WXHeaderTest)6 AppearanceHelper (com.taobao.weex.ui.component.AppearanceHelper)5