public class HardwareConfigHelper
extends java.lang.Object
HardwareConfig
object.
The base data comes from a Device
object, with additional data provided on the helper
object.
Since HardwareConfig
is immutable, this allows creating one in several (optional)
steps more easily.Constructor and Description |
---|
HardwareConfigHelper(com.android.sdklib.devices.Device device)
Creates a new helper for a given device.
|
Modifier and Type | Method and Description |
---|---|
com.android.ide.common.rendering.api.HardwareConfig |
getConfig()
Creates and returns the HardwareConfig object.
|
static java.lang.String |
getGenericLabel(com.android.sdklib.devices.Device device)
Returns a user-displayable description of the given generic device
|
static java.lang.String |
getNexusLabel(com.android.sdklib.devices.Device device)
Returns a user-displayable description of the given Nexus device
|
static java.lang.String |
getNexusMenuLabel(com.android.sdklib.devices.Device device)
Returns a user-displayable description of the given Nexus device.
|
static java.lang.String |
getResolutionString(com.android.sdklib.devices.Device device)
Returns a user displayable screen resolution string for the given device
|
static boolean |
isGeneric(com.android.sdklib.devices.Device device)
Returns true if the given device is a generic device
|
static boolean |
isMobile(com.android.sdklib.devices.Device device)
Whether the given device appears to be a mobile device (e.g.
|
static boolean |
isNexus(com.android.sdklib.devices.Device device)
Returns true if the given device is a Nexus device
|
static boolean |
isTv(com.android.sdklib.devices.Device device)
Whether the given device is a TV device
|
static boolean |
isWear(com.android.sdklib.devices.Device device)
Whether the given device is a wear device
|
static int |
nexusRank(com.android.sdklib.devices.Device device)
Returns the rank of the given nexus device.
|
HardwareConfigHelper |
setMaxRenderSize(int maxRenderWidth,
int maxRenderHeight)
Sets the max width and height to be used during rendering.
|
HardwareConfigHelper |
setOrientation(com.android.resources.ScreenOrientation screenOrientation)
Sets the orientation of the config.
|
HardwareConfigHelper |
setOverrideRenderSize(int overrideRenderWidth,
int overrideRenderHeight)
Overrides the width and height to be used during rendering.
|
static void |
sortDevicesByScreenSize(java.util.List<com.android.sdklib.devices.Device> list)
Sorts the given list of Nexus devices according to rank
|
static void |
sortNexusListByRank(java.util.List<com.android.sdklib.devices.Device> list)
Sorts the given list of Nexus devices according to rank
|
public HardwareConfigHelper(@NonNull com.android.sdklib.devices.Device device)
device
- the device to provide the base data.@NonNull public HardwareConfigHelper setOrientation(@NonNull com.android.resources.ScreenOrientation screenOrientation)
screenOrientation
- the orientation.@NonNull public HardwareConfigHelper setOverrideRenderSize(int overrideRenderWidth, int overrideRenderHeight)
Device
object.overrideRenderWidth
- the width in pixels of the layout to be renderedoverrideRenderHeight
- the height in pixels of the layout to be rendered@NonNull public HardwareConfigHelper setMaxRenderSize(int maxRenderWidth, int maxRenderHeight)
Device
object.maxRenderWidth
- the max width in pixels of the layout to be renderedmaxRenderHeight
- the max height in pixels of the layout to be rendered@NonNull public com.android.ide.common.rendering.api.HardwareConfig getConfig()
@NonNull public static java.lang.String getNexusLabel(@NonNull com.android.sdklib.devices.Device device)
device
- the device to checkisNexus(com.android.sdklib.devices.Device)
@NonNull public static java.lang.String getNexusMenuLabel(@NonNull com.android.sdklib.devices.Device device)
device
- the device to checkisNexus(com.android.sdklib.devices.Device)
@NonNull public static java.lang.String getGenericLabel(@NonNull com.android.sdklib.devices.Device device)
device
- the device to checkisGeneric(Device)
@NonNull public static java.lang.String getResolutionString(@NonNull com.android.sdklib.devices.Device device)
device
- the device to look up the string forpublic static boolean isGeneric(@NonNull com.android.sdklib.devices.Device device)
device
- the device to checkpublic static boolean isNexus(@NonNull com.android.sdklib.devices.Device device)
device
- the device to checkpublic static boolean isWear(@Nullable com.android.sdklib.devices.Device device)
public static boolean isTv(@Nullable com.android.sdklib.devices.Device device)
public static boolean isMobile(@Nullable com.android.sdklib.devices.Device device)
public static int nexusRank(com.android.sdklib.devices.Device device)
device
- the device to look up the rank forpublic static void sortNexusListByRank(@NonNull java.util.List<com.android.sdklib.devices.Device> list)
list
- the list to sortpublic static void sortDevicesByScreenSize(@NonNull java.util.List<com.android.sdklib.devices.Device> list)
list
- the list to sort