WindowSizeClassSelectors

Added in 1.4.0-alpha03

public final class WindowSizeClassSelectors


Summary

Public methods

static final @NonNull WindowSizeClass
computeWindowSizeClass(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    float widthDp,
    float heightDp
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp).

static final @NonNull WindowSizeClass
computeWindowSizeClass(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    int widthDp,
    int heightDp
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp).

static final @NonNull WindowSizeClass
computeWindowSizeClassPreferHeight(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    int widthDp,
    int heightDp
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp).

Public methods

computeWindowSizeClass

public static final @NonNull WindowSizeClass computeWindowSizeClass(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    float widthDp,
    float heightDp
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp). This method prefers width and uses max height to break ties. If there is no match a default of WindowSizeClass(0,0) is returned. Examples: Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300.5f heightDp: 800.5f Output: WindowSizeClass(300, 600) Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300 heightDp: 400 Output: WindowSizeClass(300, 300). This is an overload that truncates the floats to integers.

Parameters
float widthDp

the width of the window to match a WindowSizeClass to.

float heightDp

the height of the window to match a WindowSizeClass to.

computeWindowSizeClass

public static final @NonNull WindowSizeClass computeWindowSizeClass(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    int widthDp,
    int heightDp
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp). This method prefers width and uses max height to break ties. If there is no match a default of WindowSizeClass(0,0) is returned. Examples: Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300 heightDp: 800 Output: WindowSizeClass(300, 600) Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600) widthDp: 300 heightDp: 400 Output: WindowSizeClass(300, 300)

Parameters
int widthDp

the width of the window to match a WindowSizeClass to.

int heightDp

the height of the window to match a WindowSizeClass to.

computeWindowSizeClassPreferHeight

public static final @NonNull WindowSizeClass computeWindowSizeClassPreferHeight(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    int widthDp,
    int heightDp
)

Returns the largest WindowSizeClass that is within the bounds of (widthDp, heightDp). This method prefers height and uses max width to break ties. If there is no match a default of WindowSizeClass(0,0) is returned. Examples: Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(600, 300) widthDp: 800 heightDp: 300 Output: WindowSizeClass(600, 300) Input: Set: setOf(WindowSizeClass(300, 300), WindowSizeClass(600, 300) widthDp: 400 heightDp: 300 Output: WindowSizeClass(300, 300)

Parameters
int widthDp

the width of the window to match a WindowSizeClass to.

int heightDp

the height of the window to match a WindowSizeClass to.