@Override protected void onMeasure( ComponentContext c, ComponentLayout layout, int widthSpec, int heightSpec, Size size) { int width = SizeSpec.getSize(widthSpec); int height = SizeSpec.getSize(heightSpec); onMeasureCalled(); size.width = (measuredWidth != -1) ? SizeSpec.resolveSize(widthSpec, measuredWidth) : width; size.height = (measuredHeight != -1) ? SizeSpec.resolveSize(heightSpec, measuredHeight) : height; }
@VisibleForTesting public static int resolveWidth( int widthSpec, Layout layout, boolean minimallyWide, int minimallyWideThreshold) { final int fullWidth = SizeSpec.resolveSize(widthSpec, layout.getWidth()); if (minimallyWide && layout.getLineCount() > 1) { final int minimalWidth = SizeSpec.resolveSize(widthSpec, LayoutMeasureUtil.getWidth(layout)); if (fullWidth - minimalWidth > minimallyWideThreshold) { return minimalWidth; } } return fullWidth; }
size.height = SizeSpec.resolveSize(heightSpec, preferredHeight);