com.taobao.weex.dom.WXDomObject Java Examples
The following examples show how to use
com.taobao.weex.dom.WXDomObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXComponent.java From weex with Apache License 2.0 | 6 votes |
/** * get Scroller components */ public WXScroller getParentScroller() { WXComponent component = this; WXVContainer container; WXScroller scroller; for (; ; ) { container = component.getParent(); if (container == null) { return null; } if (container instanceof WXScroller) { scroller = (WXScroller) container; return scroller; } if (container.getRef().equals(WXDomObject.ROOT)) { return null; } component = container; } }
Example #2
Source File: AnimationAction.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void executeDom(DOMActionContext context) { try { WXDomObject domObject; if (!context.isDestory() && !TextUtils.isEmpty(animation) && (domObject = context.getDomByRef(ref)) != null) { WXAnimationBean animationBean = JSONObject.parseObject(animation, WXAnimationBean.class); if (animationBean != null && animationBean.styles != null) { int width = (int) domObject.getLayoutWidth(); int height = (int) domObject.getLayoutHeight(); animationBean.styles.init(animationBean.styles.transformOrigin, animationBean.styles.transform, width, height, context.getInstance().getInstanceViewPortWidth()); mAnimationBean = animationBean; context.postRenderTask(this); } } } catch (RuntimeException e) { WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e)); } }
Example #3
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 6 votes |
/** * get Scroller components */ public Scrollable getParentScroller() { WXComponent component = this; WXVContainer container; Scrollable scroller; for (; ; ) { container = component.getParent(); if (container == null) { return null; } if (container instanceof Scrollable) { scroller = (Scrollable) container; return scroller; } if (container.getRef().equals(WXDomObject.ROOT)) { return null; } component = container; } }
Example #4
Source File: AddEventAction.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void executeDom(DOMActionContext context) { if (context.isDestory()) { return; } WXSDKInstance instance = context.getInstance(); WXDomObject domObject = context.getDomByRef(mRef); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_ADDEVENT); } return; } domObject.addEvent(mEvent); mUpdatedDom = domObject; context.postRenderTask(this); if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } }
Example #5
Source File: UpdateAttributeAction.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void executeDom(DOMActionContext context) { if (context.isDestory()) { return; } WXSDKInstance instance = context.getInstance(); final WXDomObject domObject = context.getDomByRef(mRef); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATEATTRS); } return; } domObject.updateAttr(mData); context.postRenderTask(this); if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } }
Example #6
Source File: WXRenderStatement.java From weex-uikit with MIT License | 5 votes |
/** * set layout information of View */ void setLayout(String ref, WXDomObject domObject) { WXComponent component = mRegistry.get(ref); if (component == null) { return; } component.setLayout(domObject); }
Example #7
Source File: RenderActionContextImpl.java From ucar-weex-core with Apache License 2.0 | 5 votes |
/** * set layout information of View */ void setLayout(String ref, WXDomObject domObject) { WXComponent component = mRegistry.get(ref); if (component == null) { return; } component.setLayout(domObject); }
Example #8
Source File: WXDivTest.java From weex with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); WXDomObject divDom = Mockito.mock(WXDomObject.class); Mockito.when(divDom.getPadding()).thenReturn(new Spacing()); Mockito.when(divDom.clone()).thenReturn(divDom); divDom.ref = "1"; mWXDiv = new WXDiv(instance, divDom, null, false); mWXDiv.initView(); }
Example #9
Source File: WXListComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public WXListComponent(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy) { super(instance, node, parent); if (node != null && node instanceof WXRecyclerDomObject) { mDomObject = (WXRecyclerDomObject) node; mDomObject.preCalculateCellWidth(); if(WXBasicComponentType.WATERFALL.equals(node.getType())){ mLayoutType = WXRecyclerView.TYPE_STAGGERED_GRID_LAYOUT; }else{ mLayoutType = mDomObject.getLayoutType(); } updateRecyclerAttr(); } }
Example #10
Source File: WXRenderStatement.java From weex with Apache License 2.0 | 5 votes |
/** * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int) */ void addComponent(WXDomObject dom, String parentRef, int index) { WXVContainer parent = (WXVContainer) mRegistry.get(parentRef); WXComponent component = generateComponentTree(dom, parent); parent.addChild(component, index); WXAnimationModule.applyTransformStyle(dom.style, component); }
Example #11
Source File: WXDivTest.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@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(); }
Example #12
Source File: WXRenderManager.java From weex with Apache License 2.0 | 5 votes |
public void setLayout(String instanceId, String ref, WXDomObject domObject) { WXRenderStatement statement = mRegistries.get(instanceId); if (statement == null) { return; } statement.setLayout(ref, domObject); }
Example #13
Source File: AbstractLayoutFinishAction.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void executeDom(DOMActionContext context) { if (context.isDestory()) { return; } WXDomObject root = context.getDomByRef(WXDomObject.ROOT); mLayoutHeight = (int)root.getLayoutHeight(); mLayoutWidth = (int)root.getLayoutWidth(); context.postRenderTask(this); WXSDKInstance instance = context.getInstance(); if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } }
Example #14
Source File: MoveElementAction.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void executeDom(DOMActionContext context) { if (context.isDestory()) { return; } WXSDKInstance instance = context.getInstance(); WXDomObject domObject = context.getDomByRef(mRef); WXDomObject parentObject = context.getDomByRef(mParentRef); if (domObject == null || domObject.parent == null || parentObject == null || parentObject.hasNewLayout()) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_MOVEELEMENT); } return; } int index = mIndex; if (domObject.parent.equals(parentObject)) { if(parentObject.index(domObject) == index) { return; } else if(domObject.parent.index(domObject)< index){ index = index -1; } } mNewIndex = index; domObject.parent.remove(domObject); parentObject.add(domObject, mNewIndex); context.postRenderTask(this); if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } }
Example #15
Source File: WXRenderStatement.java From weex with Apache License 2.0 | 5 votes |
/** * set layout information of View */ void setLayout(String ref, WXDomObject domObject) { WXComponent component = mRegistry.get(ref); if (component == null) { return; } component.setLayout(domObject); }
Example #16
Source File: AddElementAction.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override protected WXComponent createComponent(DOMActionContext context, WXDomObject domObject) { WXComponent comp = context.getCompByRef(mParentRef); if (comp == null || !(comp instanceof WXVContainer)) { return null; } return generateComponentTree(context, domObject, (WXVContainer) comp); }
Example #17
Source File: WXEmbed.java From weex-uikit with MIT License | 5 votes |
public WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent) { super(instance, node, parent); mListener = new EmbedRenderListener(this); ERROR_IMG_WIDTH = (int) WXViewUtils.getRealPxByWidth(270,instance.getViewPortWidth()); ERROR_IMG_HEIGHT = (int) WXViewUtils.getRealPxByWidth(260,instance.getViewPortWidth()); if(instance instanceof EmbedManager) { Object itemId = node.getAttrs().get(ITEM_ID); if (itemId != null) { ((EmbedManager) instance).putEmbed(itemId.toString(), this); } } }
Example #18
Source File: WXTextTest.java From weex with Apache License 2.0 | 5 votes |
@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.mock(WXDomObject.class); Mockito.when(mParentDomObj.getPadding()).thenReturn(new Spacing()); Mockito.when(mParentDomObj.getBorder()).thenReturn(new Spacing()); Mockito.when(mParentDomObj.clone()).thenReturn(mParentDomObj); mParentDomObj.ref = "_root"; mDomObject = Mockito.mock(WXTextDomObject.class); mDomObject.ref = "1"; mDomObject.addEvent(WXEventType.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, false); mParent.createView(null, -1); mWXText = new WXText(instance, mDomObject, mParent, false); mWXText.setHolder(new ComponentHolder(WXText.class)); assertNotNull(instance.getContext()); }
Example #19
Source File: RemoveElementAction.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void executeDom(DOMActionContext context) { if (context.isDestory()) { return; } WXSDKInstance instance = context.getInstance(); WXDomObject domObject = context.getDomByRef(mRef); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } WXDomObject parent = domObject.parent; if (parent == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } domObject.traverseTree(context.getRemoveElementConsumer()); parent.remove(domObject); context.unregisterDOMObject(mRef); context.postRenderTask(this); if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } }
Example #20
Source File: WXSDKInstance.java From weex-uikit with MIT License | 5 votes |
private void updateRootComponentStyle(JSONObject style) { Message message = Message.obtain(); WXDomTask task = new WXDomTask(); task.instanceId = getInstanceId(); if (task.args == null) { task.args = new ArrayList<>(); } task.args.add(WXDomObject.ROOT); task.args.add(style); message.obj = task; message.what = WXDomHandler.MsgType.WX_DOM_UPDATE_STYLE; WXSDKManager.getInstance().getWXDomManager().sendMessage(message); }
Example #21
Source File: WXDivTest.java From weex with Apache License 2.0 | 5 votes |
@Test public void testAddChild(){ WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); WXDomObject testDom = Mockito.mock(WXDomObject.class); Mockito.when(testDom.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom.clone()).thenReturn(testDom); testDom.ref = "2"; WXText child1 = new WXText(instance, testDom, mWXDiv, false); child1.initView(); mWXDiv.addChild(child1, 0); assertEquals(1, mWXDiv.childCount()); WXDomObject testDom2 = Mockito.mock(WXDomObject.class); Mockito.when(testDom2.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom2.clone()).thenReturn(testDom2); testDom2.ref = "3"; child2 = new WXText(instance, testDom2, mWXDiv, false); child2.initView(); mWXDiv.addChild(child2, -1); assertEquals(2, mWXDiv.childCount()); assertEquals(child2, mWXDiv.getChild(1)); WXDomObject testDom3 = Mockito.mock(WXDomObject.class); Mockito.when(testDom3.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom3.clone()).thenReturn(testDom3); testDom3.ref = "4"; WXText child3 = new WXText(instance, testDom3, mWXDiv, false); child3.initView(); mWXDiv.addChild(child3, 1); assertEquals(3, mWXDiv.childCount()); assertEquals(child3, mWXDiv.getChild(1)); }
Example #22
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public WXComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, int type) { mInstance = instance; mContext = mInstance.getContext(); mParent = parent; mType = type; mDomObj = dom.clone(); mCurrentRef = mDomObj.getRef(); mGestureType = new HashSet<>(); ++mComponentNum; onCreate(); ComponentObserver observer; if ((observer = getInstance().getComponentObserver()) != null) { observer.onCreate(this); } }
Example #23
Source File: WXScroller.java From weex-uikit with MIT License | 4 votes |
public WXScroller(WXSDKInstance instance, WXDomObject node, WXVContainer parent) { super(instance, node, parent); stickyHelper = new WXStickyHelper(this); }
Example #24
Source File: WXSliderNeighbor.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent) { super(instance, node, parent); }
Example #25
Source File: WXRefresh.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy) { super(instance, node, parent, lazy); }
Example #26
Source File: WXScroller.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public WXScroller(WXSDKInstance instance, WXDomObject node, WXVContainer parent) { super(instance, node, parent); stickyHelper = new WXStickyHelper(this); }
Example #27
Source File: WXImageView.java From weex with Apache License 2.0 | 4 votes |
public WXImageView(Context context, WXDomObject element) { super(context); mImageShapeFeature = new WXShapeFeature(getContext(), this, element); }
Example #28
Source File: WXScroller.java From ucar-weex-core with Apache License 2.0 | 4 votes |
@Deprecated public WXScroller(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy) { this(instance,dom,parent); }
Example #29
Source File: WXA.java From weex-uikit with MIT License | 4 votes |
public WXA(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) { super(instance, dom, parent); }
Example #30
Source File: Textarea.java From weex-uikit with MIT License | 4 votes |
public Textarea(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, boolean isLazy) { super(instance, dom, parent, isLazy); }