Java Code Examples for com.facebook.litho.ComponentLayout#getPaddingBottom()

The following examples show how to use com.facebook.litho.ComponentLayout#getPaddingBottom() . 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: ImageSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
@OnBoundsDefined
static void onBoundsDefined(
    ComponentContext c,
    ComponentLayout layout,
    @Prop(resType = ResType.DRAWABLE) Drawable drawable,
    @Prop(optional = true) ScaleType scaleType,
    Output<DrawableMatrix> drawableMatrix,
    Output<Integer> drawableWidth,
    Output<Integer> drawableHeight) {

  final int horizontalPadding = layout.getPaddingLeft() + layout.getPaddingRight();
  final int verticalPadding = layout.getPaddingTop() + layout.getPaddingBottom();

  if (ScaleType.FIT_XY == scaleType
      || drawable == null
      || drawable.getIntrinsicWidth() <= 0
      || drawable.getIntrinsicHeight() <= 0) {
    drawableMatrix.set(null);
    drawableWidth.set(layout.getWidth() - horizontalPadding);
    drawableHeight.set(layout.getHeight() - verticalPadding);
  } else {
    final DrawableMatrix matrix =
        DrawableMatrix.create(
            drawable,
            scaleType,
            layout.getWidth() - horizontalPadding,
            layout.getHeight() - verticalPadding);

    drawableMatrix.set(matrix);
    drawableWidth.set(drawable.getIntrinsicWidth());
    drawableHeight.set(drawable.getIntrinsicHeight());
  }
}
 
Example 2
Source File: VerticalScrollSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
@OnBoundsDefined
static void onBoundsDefined(
    ComponentContext c,
    ComponentLayout layout,
    @Prop Component childComponent,
    @Prop(optional = true) boolean fillViewport,
    @State ComponentTree childComponentTree,
    @FromMeasure Integer measuredWidth,
    @FromMeasure Integer measuredHeight) {

  final int layoutWidth = layout.getWidth() - layout.getPaddingLeft() - layout.getPaddingRight();
  final int layoutHeight =
      layout.getHeight() - layout.getPaddingTop() - layout.getPaddingBottom();

  if (measuredWidth != null
      && measuredWidth == layoutWidth
      && (!fillViewport || (measuredHeight != null && measuredHeight == layoutHeight))) {
    // If we're not filling the viewport, then we always measure the height with unspecified, so
    // we just need to check that the width matches.
    return;
  }

  measureVerticalScroll(
      c,
      SizeSpec.makeSizeSpec(layout.getWidth(), EXACTLY),
      SizeSpec.makeSizeSpec(layout.getHeight(), EXACTLY),
      new Size(),
      childComponentTree,
      childComponent,
      fillViewport);
}
 
Example 3
Source File: FrescoVitoImage2Spec.java    From fresco with MIT License 5 votes vote down vote up
@OnBoundsDefined
static void onBoundsDefined(
    ComponentContext c, ComponentLayout layout, Output<Rect> viewportDimensions) {
  final int width = layout.getWidth();
  final int height = layout.getHeight();
  int paddingX = 0, paddingY = 0;
  if (layout.isPaddingSet()) {
    paddingX = layout.getPaddingLeft() + layout.getPaddingRight();
    paddingY = layout.getPaddingTop() + layout.getPaddingBottom();
  }

  viewportDimensions.set(new Rect(0, 0, width - paddingX, height - paddingY));
}