com.android.ide.common.rendering
Class HardwareConfigHelper

java.lang.Object
  extended by com.android.ide.common.rendering.HardwareConfigHelper

public class HardwareConfigHelper
extends java.lang.Object

Helper method to create a 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.


Field Summary
static java.lang.String MANUFACTURER_GENERIC
          Manufacturer used by the generic devices in the device list
 
Constructor Summary
HardwareConfigHelper(com.android.sdklib.devices.Device device)
          Creates a new helper for a given device.
 
Method Summary
 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 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 isNexus(com.android.sdklib.devices.Device device)
          Returns true if the given device is a Nexus 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 sortNexusList(java.util.List<com.android.sdklib.devices.Device> list)
          Sorts the given list of Nexus devices according to rank
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANUFACTURER_GENERIC

public static final java.lang.String MANUFACTURER_GENERIC
Manufacturer used by the generic devices in the device list

See Also:
Constant Field Values
Constructor Detail

HardwareConfigHelper

public HardwareConfigHelper(@NonNull
                            com.android.sdklib.devices.Device device)
Creates a new helper for a given device.

Parameters:
device - the device to provide the base data.
Method Detail

setOrientation

@NonNull
public HardwareConfigHelper setOrientation(@NonNull
                                                   com.android.resources.ScreenOrientation screenOrientation)
Sets the orientation of the config.

Parameters:
screenOrientation - the orientation.
Returns:
this (such that chains of setters can be stringed together)

setOverrideRenderSize

@NonNull
public HardwareConfigHelper setOverrideRenderSize(int overrideRenderWidth,
                                                          int overrideRenderHeight)
Overrides the width and height to be used during rendering. A value of -1 will make the rendering use the normal width and height coming from the Device object.

Parameters:
overrideRenderWidth - the width in pixels of the layout to be rendered
overrideRenderHeight - the height in pixels of the layout to be rendered
Returns:
this (such that chains of setters can be stringed together)

setMaxRenderSize

@NonNull
public HardwareConfigHelper setMaxRenderSize(int maxRenderWidth,
                                                     int maxRenderHeight)
Sets the max width and height to be used during rendering. A value of -1 will make the rendering use the normal width and height coming from the Device object.

Parameters:
maxRenderWidth - the max width in pixels of the layout to be rendered
maxRenderHeight - the max height in pixels of the layout to be rendered
Returns:
this (such that chains of setters can be stringed together)

getConfig

@NonNull
public com.android.ide.common.rendering.api.HardwareConfig getConfig()
Creates and returns the HardwareConfig object.

Returns:
the config

getNexusLabel

@NonNull
public static java.lang.String getNexusLabel(@NonNull
                                                     com.android.sdklib.devices.Device device)
Returns a user-displayable description of the given Nexus device

Parameters:
device - the device to check
Returns:
the label
See Also:
isNexus(com.android.sdklib.devices.Device)

getGenericLabel

@NonNull
public static java.lang.String getGenericLabel(@NonNull
                                                       com.android.sdklib.devices.Device device)
Returns a user-displayable description of the given generic device

Parameters:
device - the device to check
Returns:
the label
See Also:
isGeneric(com.android.sdklib.devices.Device)

getResolutionString

@NonNull
public static java.lang.String getResolutionString(@NonNull
                                                           com.android.sdklib.devices.Device device)
Returns a user displayable screen resolution string for the given device

Parameters:
device - the device to look up the string for
Returns:
a user displayable string

isGeneric

public static boolean isGeneric(@NonNull
                                com.android.sdklib.devices.Device device)
Returns true if the given device is a generic device

Parameters:
device - the device to check
Returns:
true if the device is generic

isNexus

public static boolean isNexus(@NonNull
                              com.android.sdklib.devices.Device device)
Returns true if the given device is a Nexus device

Parameters:
device - the device to check
Returns:
true if the device is a Nexus

nexusRank

public static int nexusRank(com.android.sdklib.devices.Device device)
Returns the rank of the given nexus device. This can be used to order the devices chronologically.

Parameters:
device - the device to look up the rank for
Returns:
the rank of the device

sortNexusList

public static void sortNexusList(@NonNull
                                 java.util.List<com.android.sdklib.devices.Device> list)
Sorts the given list of Nexus devices according to rank

Parameters:
list - the list to sort