Search in sources :

Example 21 with WXDomObject

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

the class Statements method copyComponentTree.

/**
 * recursive copy component,
 */
private static final WXComponent copyComponentTree(WXComponent source, WXVContainer parent) {
    WXDomObject node = (WXDomObject) source.getDomObject();
    WXComponent component = WXComponentFactory.newInstance(source.getInstance(), node, parent);
    if (source instanceof WXVContainer) {
        WXVContainer container = (WXVContainer) source;
        WXVContainer childParent = (WXVContainer) component;
        WXDomObject childParentNode = (WXDomObject) childParent.getDomObject();
        int count = container.getChildCount();
        for (int i = 0; i < count; ++i) {
            WXComponent child = container.getChild(i);
            if (child != null) {
                WXComponent targetChild = copyComponentTree(child, childParent);
                childParent.addChild(targetChild);
                childParentNode.add((WXDomObject) targetChild.getDomObject(), -1);
            }
        }
    }
    // copy info need be sync
    if (source.isWaste()) {
        component.setWaste(true);
    }
    return component;
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXDomObject(com.taobao.weex.dom.WXDomObject) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 22 with WXDomObject

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

the class WXComponent method setWaste.

/**
 * mark node waste,
 * if node is waster should hidden, and dom tree should allow not show
 */
public void setWaste(boolean waste) {
    if (this.waste != waste) {
        this.waste = waste;
        WXDomObject domObject = (WXDomObject) getDomObject();
        if (waste) {
            // update dom not show, and put style to hidden
            domObject.setVisible(false);
            domObject.getStyles().put(Constants.Name.VISIBILITY, Constants.Value.HIDDEN);
            // if component not init, mark lazy init when use, reduce view count
            if (getHostView() == null) {
                if (!mLazy) {
                    lazy(true);
                }
            } else {
                getHostView().setVisibility(View.GONE);
            }
        } else {
            domObject.setVisible(true);
            domObject.getStyles().put(Constants.Name.VISIBILITY, Constants.Value.VISIBLE);
            if (getHostView() == null) {
                if (mLazy) {
                    // when parent is lazy just mark node lazy false
                    if (mParent != null && mParent.isLazy()) {
                        lazy(false);
                    } else {
                        ComponentUtils.initLazyComponent(this, mParent);
                    }
                }
            } else {
                getHostView().setVisibility(View.VISIBLE);
            }
        }
    }
}
Also used : WXDomObject(com.taobao.weex.dom.WXDomObject)

Example 23 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project WeexErosFramework by bmfe.

the class BMRich method organizeChild.

private void organizeChild(WXDomObject object) {
    if (object instanceof WXTextDomObject) {
        WXTextDomObject textDomObject = (WXTextDomObject) object;
        BMRichUtil util = new BMRichUtil();
        Spanned test = util.createSpan(textDomObject.getAttrs(), textDomObject.getStyles());
        SpannableString spannableString = ((SpannableString) test);
        Object[] spans = spannableString.getSpans(0, spannableString.length(), Object.class);
        for (Object span : spans) {
            mSpans.add(new RichTextDomObject.BMRichSpan(span, mText.length(), spannableString.length() + mText.length()));
        }
        // 设置span的事件
        WXEvent events = object.getEvents();
        for (String event : events) {
            appendChildEvent(event, spannableString, textDomObject);
        }
        mText.append(spannableString.toString());
        spannableStringBuilder.append(spannableString);
    }
    update();
}
Also used : SpannableString(android.text.SpannableString) RichTextDomObject(com.taobao.weex.dom.RichTextDomObject) WXEvent(com.taobao.weex.dom.WXEvent) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) WXDomObject(com.taobao.weex.dom.WXDomObject) ImmutableDomObject(com.taobao.weex.dom.ImmutableDomObject) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) RichTextDomObject(com.taobao.weex.dom.RichTextDomObject) JSONObject(com.alibaba.fastjson.JSONObject) SpannableString(android.text.SpannableString) BMRichUtil(com.eros.framework.utils.BMRichUtil) Spanned(android.text.Spanned)

Example 24 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project WeexErosFramework by bmfe.

the class BMPop method getAnimationHeight.

private void getAnimationHeight() {
    WXDomObject wxDomObject = (WXDomObject) getDomObject();
    if (wxDomObject == null)
        return;
    WXStyle wxStyle = wxDomObject.getStyles();
    Object object = wxStyle.get("height");
    if (object == null)
        return;
    mHeight = Integer.valueOf(object.toString());
}
Also used : WXStyle(com.taobao.weex.dom.WXStyle) WXDomObject(com.taobao.weex.dom.WXDomObject) WXDomObject(com.taobao.weex.dom.WXDomObject)

Example 25 with WXDomObject

use of com.taobao.weex.dom.WXDomObject in project weex-example by KalicyZhou.

the class WXListComponentTest method testParseTransforms.

@Test
public void testParseTransforms() throws Exception {
    WXDiv div = WXDivTest.create();
    ComponentTest.create(div);
    WXDomObject dom = new WXListDomObject();
    dom.getAttrs().put(WXListComponent.TRANSFORM, "scale(0.9,0.8);translate(10,20);opacity(0.5);rotate(100)");
    component = create(div, dom);
    ComponentTest.create(component);
}
Also used : WXDiv(com.taobao.weex.ui.component.WXDiv) WXListDomObject(com.taobao.weex.dom.WXListDomObject) WXDomObject(com.taobao.weex.dom.WXDomObject) Test(org.junit.Test) ComponentTest(com.taobao.weex.ui.component.ComponentTest) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest) WXHeaderTest(com.taobao.weex.ui.component.WXHeaderTest) WXDivTest(com.taobao.weex.ui.component.WXDivTest)

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