FromMeasure

Annotates that the argument's value should be set to the named inter-stage output from the lifecycle method. The name and type of the argument must match with the inter-stage output requested.

This can be used in:

The annotation processor will validate this and other invariants in the API at build time.

For example:

@MountSpec
public class SubtitleSpec {

 @OnMeasure
  static void onMeasure(
      ComponentContext componentContext,
      ComponentLayout layout,
      int widthSpec,
      int heightSpec,
      Size size,
     @Prop String text,
      Output<Layout> measuredLayout) {

    Layout textLayout = createTextLayout(text, widthSpec, heightSpec);

    size.width = SizeSpec.resolveSize(widthSpec, textLayout.getWidth());
    size.height = SizeSpec.resolveSize(heightSpec, LayoutMeasureUtil.getHeight(textLayout));

    if (size.width < 0 || size.height < 0) {
      size.width = Math.max(size.width, 0);
      size.height = Math.max(size.height, 0);
    }

    measuredLayout.set(textLayout);  // Set the value of output.
  }

 @OnMount
  static void onMount(ComponentContext c,
    TextDrawable textDrawable,
   @Prop String text,
    // Get measured layout from the output set in OnMeasure.
   @FromMeasure Layout measuredLayout) {

      textDrawable.mount(
        text,
        textLayout,
        0,
        null,
        Color.BLANK,
        Color.GREEN,
        null);
  }
}

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun toString(): String