com.taobao.weex.dom.flex.MeasureOutput Java Examples
The following examples show how to use
com.taobao.weex.dom.flex.MeasureOutput.
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: WXSwitchDomObject.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void measure(CSSNode node, float width, MeasureOutput measureOutput) { try { Context context=((WXDomObject) node).getDomContext().getUIContext(); WXSwitchView wxSwitchView = new WXSwitchView(context); int widthSpec, heightSpec; heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); if (Float.isNaN(width)) { widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } else { widthSpec = MeasureSpec.makeMeasureSpec((int) width, MeasureSpec.AT_MOST); } wxSwitchView.measure(widthSpec, heightSpec); measureOutput.width = wxSwitchView.getMeasuredWidth(); measureOutput.height = wxSwitchView.getMeasuredHeight(); } catch (RuntimeException e) { WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e)); } }
Example #2
Source File: WXTextDomObject.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void measure(CSSNode node, float width, @NonNull MeasureOutput measureOutput) { WXTextDomObject textDomObject = (WXTextDomObject) node; if (CSSConstants.isUndefined(width)) { width = node.cssstyle.maxWidth; } if(textDomObject.getTextWidth(textDomObject.mTextPaint,width,false)>0) { textDomObject.layout = textDomObject.createLayout(width, false, null); textDomObject.hasBeenMeasured = true; textDomObject.previousWidth = textDomObject.layout.getWidth(); measureOutput.height = textDomObject.layout.getHeight(); measureOutput.width = textDomObject.previousWidth; }else{ measureOutput.height = 0; measureOutput.width = 0; } }
Example #3
Source File: WXSwitchDomObject.java From weex-uikit with MIT License | 6 votes |
@Override public void measure(CSSNode node, float width, MeasureOutput measureOutput) { try { if (!measured) { WXSwitchView wxSwitchView = new WXSwitchView(((WXDomObject) node).getDomContext().getUIContext()); int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int widthSpec = View.MeasureSpec.makeMeasureSpec((int) width, View.MeasureSpec.AT_MOST); wxSwitchView.measure(widthSpec, heightSpec); mWidth = wxSwitchView.getMeasuredWidth(); mHeight = wxSwitchView.getMeasuredHeight(); measured = true; } measureOutput.width = mWidth; measureOutput.height = mHeight; } catch (RuntimeException e) { WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e)); } }
Example #4
Source File: WXTextDomObject.java From weex-uikit with MIT License | 6 votes |
@Override public void measure(CSSNode node, float width, @NonNull MeasureOutput measureOutput) { WXTextDomObject textDomObject = (WXTextDomObject) node; if (CSSConstants.isUndefined(width)) { width = node.cssstyle.maxWidth; } if(textDomObject.getTextWidth(textDomObject.mTextPaint,width,false)>0) { textDomObject.layout = textDomObject.createLayout(width, false, null); textDomObject.hasBeenMeasured = true; textDomObject.previousWidth = textDomObject.layout.getWidth(); measureOutput.height = textDomObject.layout.getHeight(); measureOutput.width = textDomObject.previousWidth; }else{ measureOutput.height = 0; measureOutput.width = 0; } }
Example #5
Source File: BasicEditTextDomObject.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public BasicEditTextDomObject() { super(); mPaint.setTextSize(WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,getViewPortWidth())); setMeasureFunction(new MeasureFunction() { @Override public void measure(CSSNode node, float width, MeasureOutput measureOutput) { if (CSSConstants.isUndefined(width)) { width = node.cssstyle.maxWidth; } measureOutput.height = getMeasureHeight(); measureOutput.width = width; } }); }
Example #6
Source File: WXTextDomObjectTest.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Test public void testMeasure() throws Exception { testLayoutBefore(); MeasureOutput output = new MeasureOutput(); WXTextDomObject mock = PowerMockito.spy(dom); PowerMockito.when(mock,"getTextWidth",dom.getTextPaint(),100f,false).thenReturn(10f); WXTextDomObject.TEXT_MEASURE_FUNCTION.measure(mock,100,output); assertEquals(output.width,10f,0.1f); }
Example #7
Source File: BasicEditTextDomObject.java From weex-uikit with MIT License | 5 votes |
public BasicEditTextDomObject() { super(); mPaint.setTextSize(WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,getViewPortWidth())); setMeasureFunction(new MeasureFunction() { @Override public void measure(CSSNode node, float width, MeasureOutput measureOutput) { if (CSSConstants.isUndefined(width)) { width = node.cssstyle.maxWidth; } measureOutput.height = getMeasureHeight(); measureOutput.width = width; } }); }
Example #8
Source File: WXTextDomObjectTest.java From weex-uikit with MIT License | 5 votes |
@Test public void testMeasure() throws Exception { testLayoutBefore(); MeasureOutput output = new MeasureOutput(); WXTextDomObject mock = PowerMockito.spy(dom); PowerMockito.when(mock,"getTextWidth",dom.getTextPaint(),100f,false).thenReturn(10f); WXTextDomObject.TEXT_MEASURE_FUNCTION.measure(mock,100,output); assertEquals(output.width,10f,0.1f); }
Example #9
Source File: WXTextDomObject.java From weex with Apache License 2.0 | 5 votes |
@Override public void measure(CSSNode node, float width, MeasureOutput measureOutput) { WXTextDomObject textDomObject = (WXTextDomObject) node; if (CSSConstants.isUndefined(width)) { width = node.cssstyle.maxWidth; } textDomObject.updateLayout(width,false); textDomObject.hasBeenMeasured = true; textDomObject.previousWidth = textDomObject.layout.getWidth(); measureOutput.height = textDomObject.layout.getHeight(); measureOutput.width = textDomObject.previousWidth; }