Search in sources :

Example 1 with WXDomObject

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

the class WXTextTest method setUp.

@Before
public void setUp() throws Exception {
    WXEnvironment.sApplication = RuntimeEnvironment.application;
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);
    mParentDomObj = Mockito.spy(new WXDomObject());
    Mockito.when(mParentDomObj.getPadding()).thenReturn(new Spacing());
    Mockito.when(mParentDomObj.getBorder()).thenReturn(new Spacing());
    Mockito.when(mParentDomObj.clone()).thenReturn(mParentDomObj);
    TestDomObject.setRef(mParentDomObj, WXDomObject.ROOT);
    mDomObject = Mockito.spy(new WXTextDomObject());
    TestDomObject.setRef(mDomObject, "1");
    mDomObject.addEvent(Constants.Event.CLICK);
    Mockito.when(mDomObject.clone()).thenReturn(mDomObject);
    Mockito.when(mDomObject.getPadding()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getBorder()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getMargin()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getLayoutWidth()).thenReturn(100f);
    Mockito.when(mDomObject.getLayoutHeight()).thenReturn(100f);
    mParent = new WXDiv(instance, mParentDomObj, null);
    mParent.createView();
    mWXText = new WXText(instance, mDomObject, mParent);
    mWXText.bindHolder(new SimpleComponentHolder(WXText.class));
    assertNotNull(instance.getContext());
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) SimpleComponentHolder(com.taobao.weex.ui.SimpleComponentHolder) Spacing(com.taobao.weex.dom.flex.Spacing) Before(org.junit.Before)

Example 2 with WXDomObject

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

the class WXDivTest method setUp.

@Before
public void setUp() throws Exception {
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);
    WXDomObject divDom = new WXDomObject();
    WXDomObject spy = Mockito.spy(divDom);
    Mockito.when(spy.getPadding()).thenReturn(new Spacing());
    Mockito.when(spy.getEvents()).thenReturn(new WXEvent());
    Mockito.when(spy.clone()).thenReturn(divDom);
    TestDomObject.setRef(divDom, "1");
    mWXDiv = new WXDiv(instance, divDom, null);
    mWXDiv.initView();
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject) WXEvent(com.taobao.weex.dom.WXEvent) Spacing(com.taobao.weex.dom.flex.Spacing) Before(org.junit.Before)

Example 3 with WXDomObject

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

the class WXRenderStatement method generateComponentTree.

private WXComponent generateComponentTree(WXDomObject dom, WXVContainer parent) {
    if (dom == null) {
        return null;
    }
    WXComponent component = WXComponentFactory.newInstance(mWXSDKInstance, dom, parent);
    mRegistry.put(dom.getRef(), component);
    if (component instanceof WXVContainer) {
        WXVContainer parentC = (WXVContainer) component;
        int count = dom.childCount();
        WXDomObject child = null;
        for (int i = 0; i < count; ++i) {
            child = dom.getChild(i);
            if (child != null) {
                parentC.addChild(generateComponentTree(child, parentC));
            }
        }
    }
    return component;
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent) WXDomObject(com.taobao.weex.dom.WXDomObject)

Example 4 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 5 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) SpannableString(android.text.SpannableString) BMRichUtil(com.benmu.framework.utils.BMRichUtil) Spanned(android.text.Spanned)

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