gpt4 book ai didi

com.facebook.yoga.YogaMeasureFunction.measure()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 11:47:31 34 4
gpt4 key购买 nike

本文整理了Java中com.facebook.yoga.YogaMeasureFunction.measure()方法的一些代码示例,展示了YogaMeasureFunction.measure()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YogaMeasureFunction.measure()方法的具体详情如下:
包路径:com.facebook.yoga.YogaMeasureFunction
类名称:YogaMeasureFunction
方法名:measure

YogaMeasureFunction.measure介绍

[英]Return a value created by YogaMeasureOutput.make(width, height);
[中]返回由YogaMeasureOutput创建的值。制造(宽度、高度);

代码示例

代码示例来源:origin: facebook/litho

private long measureInternalNode(
    InternalNode node,
    float widthConstranint,
    float heightConstraint) {
 final YogaMeasureFunction measureFunc =
     Whitebox.getInternalState(
         node.mYogaNode,
         "mMeasureFunction");
 return measureFunc.measure(
     node.mYogaNode,
     widthConstranint,
     EXACTLY,
     heightConstraint,
     EXACTLY);
}

代码示例来源:origin: facebook/litho

@Test
public void testOnMeasureNotOverriden() {
 Component component = setUpSpyComponentForCreateLayout(true, true);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 try {
  measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
  fail();
 } catch (Exception e) {
  assertThat(e).isExactlyInstanceOf(IllegalStateException.class);
  assertThat(e.getMessage()).contains("canMeasure()");
 }
}

代码示例来源:origin: facebook/litho

@Test
public void testMountSpecYogaMeasureOutputNotSet() {
 Component component = new TestMountSpecWithEmptyOnMeasure(mNode);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 try {
  measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
  fail();
 } catch (Exception e) {
  assertThat(e).isExactlyInstanceOf(IllegalStateException.class);
  assertThat(e.getMessage()).contains("MeasureOutput not set");
 }
}

代码示例来源:origin: facebook/litho

@Test
public void testLayoutSpecMeasureResolveNestedTree() {
 Component component = setUpSpyComponentForCreateLayout(
   false /* isMountSpec */, true /* canMeasure */);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 final int nestedTreeWidth = 20;
 final int nestedTreeHeight = 25;
 InternalNode nestedTree = mock(InternalNode.class);
 when(nestedTree.getWidth()).thenReturn(nestedTreeWidth);
 when(nestedTree.getHeight()).thenReturn(nestedTreeHeight);
 when(LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt()))
   .thenReturn(nestedTree);
 when(mNode.getContext()).thenReturn(mContext);
 long output = measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
 PowerMockito.verifyStatic();
 LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt());
 assertThat(YogaMeasureOutput.getWidth(output)).isEqualTo(nestedTreeWidth);
 assertThat(YogaMeasureOutput.getHeight(output)).isEqualTo(nestedTreeHeight);
}

代码示例来源:origin: facebook/litho

@Test
public void testLayoutSpecMeasureResolveNestedTree_withExperiment() {
 Component component =
   setUpSpyComponentForCreateLayout(false /* isMountSpec */, true /* canMeasure */);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 final int nestedTreeWidth = 20;
 final int nestedTreeHeight = 25;
 InternalNode nestedTree = mock(InternalNode.class);
 when(nestedTree.getWidth()).thenReturn(nestedTreeWidth);
 when(nestedTree.getHeight()).thenReturn(nestedTreeHeight);
 when(LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt()))
   .thenReturn(nestedTree);
 when(mNode.getContext()).thenReturn(mContext);
 when(mContext.isNestedTreeResolutionExperimentEnabled()).thenReturn(true);
 when(mNode.getParent()).thenReturn(mNode);
 when(mNode.getContext()).thenReturn(mContext);
 long output = measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
 PowerMockito.verifyStatic();
 LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt());
 assertThat(YogaMeasureOutput.getWidth(output)).isEqualTo(nestedTreeWidth);
 assertThat(YogaMeasureOutput.getHeight(output)).isEqualTo(nestedTreeHeight);
}

代码示例来源:origin: facebook/litho

@Test
public void testMountSpecYogaMeasureOutputSet() {
 Component component = new TestMountSpecSettingSizesInOnMeasure(mNode);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 long output = measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
 assertThat(YogaMeasureOutput.getWidth(output)).isEqualTo(A_WIDTH);
 assertThat(YogaMeasureOutput.getHeight(output)).isEqualTo(A_HEIGHT);
}

代码示例来源:origin: koudle/AndYogaSample

@DoNotStrip
public final long measure(float width, int widthMode, float height, int heightMode) {
 if (!isMeasureDefined()) {
  throw new RuntimeException("Measure function isn't defined!");
 }
 return mMeasureFunction.measure(
    this,
    width,
    YogaMeasureMode.values()[widthMode],
    height,
    YogaMeasureMode.values()[heightMode]);
}

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com