Java Code Examples for com.facebook.yoga.YogaEdge#TOP

The following examples show how to use com.facebook.yoga.YogaEdge#TOP . 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: Border.java    From litho with Apache License 2.0 6 votes vote down vote up
static YogaEdge edgeFromIndex(int i) {
  if (i < 0 || i >= EDGE_COUNT) {
    throw new IllegalArgumentException("Given index out of range of acceptable edges: " + i);
  }
  switch (i) {
    case EDGE_LEFT:
      return YogaEdge.LEFT;
    case EDGE_TOP:
      return YogaEdge.TOP;
    case EDGE_RIGHT:
      return YogaEdge.RIGHT;
    case EDGE_BOTTOM:
      return YogaEdge.BOTTOM;
  }
  throw new IllegalArgumentException("Given unknown edge index: " + i);
}
 
Example 2
Source File: Edges.java    From litho with Apache License 2.0 5 votes vote down vote up
public float get(YogaEdge edge) {
  float defaultValue =
      (edge == YogaEdge.START || edge == YogaEdge.END ? YogaConstants.UNDEFINED : DEFAULT_VALUE);

  // Nothing is set.
  if (mEdgesToValuesIndex == ~0) {
    return defaultValue;
  }

  final byte edgeIndex = getIndex(edge.intValue());
  if (edgeIndex != UNDEFINED_INDEX) {
    return mValues[edgeIndex];
  }

  if (mHasAliasesSet) {
    final int secondTypeEdgeValue =
        edge == YogaEdge.TOP || edge == YogaEdge.BOTTOM ? VERTICAL_INTVALUE : HORIZONTAL_INTVALUE;
    final byte secondTypeEdgeIndex = getIndex(secondTypeEdgeValue);

    if (secondTypeEdgeIndex != UNDEFINED_INDEX) {
      return mValues[secondTypeEdgeIndex];

    } else if (getIndex(ALL_INTVALUE) != UNDEFINED_INDEX) {
      return mValues[getIndex(ALL_INTVALUE)];
    }
  }

  return defaultValue;
}