Package com.castlabs.android.utils
Class ScreenUtils
java.lang.Object
com.castlabs.android.utils.ScreenUtils
Utility class that provides helper methods around the device screen
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic DisplaygetDisplay(Context context) Resolves a display for the given context without requiring a UI context.static PointgetScreenSize(Context context) Deprecated.static PointgetWindowSize(Context context) Returns the best available playback size in pixels for track-selection decisions.
-
Method Details
-
getScreenSize
Deprecated.Returns the dimensions of the device screen in pixel. Please note that this method ignores the current orientation of the device.- Parameters:
context- The context- Returns:
- Point that holds the width and height of the screen in pixel
-
getWindowSize
Returns the best available playback size in pixels for track-selection decisions.If the provided context is a UI context, this method prefers window bounds (
WindowManager.getCurrentWindowMetrics()on API 30+) so multi-window playback uses the actual window size. If a window-specific size is not available, it falls back to the current display mode size for the resolved display.For non-visual contexts, this method avoids direct visual-service access through
Context.WINDOW_SERVICEand resolves the display viagetDisplay(Context).- Parameters:
context- Any context (UI or non-UI)- Returns:
- A
Pointwith width/height in pixels, or(Integer.MAX_VALUE, Integer.MAX_VALUE)when no display can be resolved
-
getDisplay
Resolves a display for the given context without requiring a UI context.The default display is preferred; if unavailable, the first available display from
DisplayManager.getDisplays()is returned.- Parameters:
context- Any context- Returns:
- The resolved
Display, ornullif no display is available
-
getWindowSize(Context)