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());
}
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();
}
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;
}
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());
}
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();
}
Aggregations