@UnstableApi
public final class CueUtil


Utility methods and constants for Cue layout and styling.

Summary

Constants

static final float

The default bottom padding to apply when line is DIMEN_UNSET, as a fraction of the viewport height.

static final float

The default fractional text size, as a fraction of the viewport height.

Public methods

static float
resolveAnchorOffset(
    float fractionalPosition,
    @Cue.AnchorType int anchorType,
    int cueDimension,
    int viewDimension
)

Calculates the pixel offset for placing a cue along a given axis (X or Y) relative to the viewport.

static float
resolveTextSize(
    @Cue.TextSizeType int textSizeType,
    float textSize,
    int rawViewHeight,
    int viewHeightMinusPadding
)

Returns the text size in px, derived from textSize and textSizeType.

Constants

DEFAULT_BOTTOM_PADDING_FRACTION

public static final float DEFAULT_BOTTOM_PADDING_FRACTION = 0.08f

The default bottom padding to apply when line is DIMEN_UNSET, as a fraction of the viewport height.

DEFAULT_TEXT_SIZE_FRACTION

public static final float DEFAULT_TEXT_SIZE_FRACTION = 0.0533f

The default fractional text size, as a fraction of the viewport height.

Public methods

resolveAnchorOffset

public static float resolveAnchorOffset(
    float fractionalPosition,
    @Cue.AnchorType int anchorType,
    int cueDimension,
    int viewDimension
)

Calculates the pixel offset for placing a cue along a given axis (X or Y) relative to the viewport.

If fractionalPosition is DIMEN_UNSET, the cue is centered within the viewport. Otherwise, the offset is determined by aligning the specified anchorType of the cue with the fractionalPosition of the viewport.

Parameters
float fractionalPosition

The position of the cue's anchor, expressed as a fraction (between 0 and 1) of viewDimension, or DIMEN_UNSET.

@Cue.AnchorType int anchorType

The anchor type (e.g., ANCHOR_TYPE_START, ANCHOR_TYPE_MIDDLE, ANCHOR_TYPE_END).

int cueDimension

The pixel dimension (width or height) of the cue.

int viewDimension

The pixel dimension (width or height) of the viewport.

Returns
float

The pixel offset of the start (top or left) of the cue, relative to the start (top or left) of the viewport.

resolveTextSize

public static float resolveTextSize(
    @Cue.TextSizeType int textSizeType,
    float textSize,
    int rawViewHeight,
    int viewHeightMinusPadding
)

Returns the text size in px, derived from textSize and textSizeType.

Returns DIMEN_UNSET if textSize == Cue.DIMEN_UNSET or textSizeType == Cue.TYPE_UNSET.