WindowSizeClassScoreCalculatorKt


public final class WindowSizeClassScoreCalculatorKt


Summary

Public methods

static final int
@ExperimentalWindowCoreApi
scoreWithinAreaBounds(
    @NonNull WindowSizeClass receiver,
    int windowWidthDp,
    int windowHeightDp
)

A scoring function to calculate how close the area of a WindowSizeClass is to the area of a window without exceeding it.

static final int

A scoring function to calculate how close the height of a WindowSizeClass is to heightDp without exceeding it.

static final int

A scoring function to calculate how close the width of a WindowSizeClass is to widthDp without exceeding it.

Public methods

scoreWithinAreaBounds

@ExperimentalWindowCoreApi
public static final int scoreWithinAreaBounds(
    @NonNull WindowSizeClass receiver,
    int windowWidthDp,
    int windowHeightDp
)

A scoring function to calculate how close the area of a WindowSizeClass is to the area of a window without exceeding it.

Parameters
int windowWidthDp

the width of a window constraint.

int windowHeightDp

the height of a window constraint.

Returns
int

an integer from -1 to Integer.MAX_VALUE where a larger value indicates a better match.

scoreWithinHeightDp

@ExperimentalWindowCoreApi
public static final int scoreWithinHeightDp(@NonNull WindowSizeClass receiver, int heightDp)

A scoring function to calculate how close the height of a WindowSizeClass is to heightDp without exceeding it.

Parameters
int heightDp

the height bound to try to match.

Returns
int

an integer from -1 to Integer.MAX_VALUE where a larger value indicates a better match.

scoreWithinWidthDp

@ExperimentalWindowCoreApi
public static final int scoreWithinWidthDp(@NonNull WindowSizeClass receiver, int widthDp)

A scoring function to calculate how close the width of a WindowSizeClass is to widthDp without exceeding it.

Parameters
int widthDp

the width bound to try to match.

Returns
int

an integer from -1 to Integer.MAX_VALUE where a larger value indicates a better match.