public class LayoutLibrary
extends java.lang.Object
Use load(String, ILogger, String)
to load the jar file.
Use the layout library with:
init(java.util.Map<java.lang.String, java.lang.String>, java.io.File, java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>>, com.android.ide.common.rendering.api.LayoutLog)
, supports(int)
, createSession(SessionParams)
,
dispose()
, clearCaches(Object)
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_BRIDGE |
static java.lang.String |
FN_ICU_JAR |
Modifier | Constructor and Description |
---|---|
protected |
LayoutLibrary() |
Modifier and Type | Method and Description |
---|---|
void |
clearCaches(java.lang.Object projectKey)
Clears the resource cache for a specific project.
|
com.android.ide.common.rendering.api.RenderSession |
createSession(com.android.ide.common.rendering.api.SessionParams params)
Starts a layout session by inflating and rendering it.
|
boolean |
dispose()
Prepares the layoutlib to unloaded.
|
int |
getApiLevel()
Returns the API level of the layout library.
|
java.lang.ClassLoader |
getClassLoader()
Returns the classloader used to load the classes in the layoutlib jar file.
|
java.lang.String |
getLoadMessage()
Returns the message associated with the
LoadStatus . |
int |
getRevision()
Returns the revision of the library inside a given (layoutlib) API level.
|
LoadStatus |
getStatus()
Returns the
LoadStatus of the loading of the layoutlib jar file. |
com.android.ide.common.rendering.api.Result |
getViewIndex(java.lang.Object viewObject)
Utility method returning the index of a given view in its parent.
|
com.android.ide.common.rendering.api.Result |
getViewParent(java.lang.Object viewObject)
Utility method returning the parent of a given view object.
|
boolean |
init(java.util.Map<java.lang.String,java.lang.String> platformProperties,
java.io.File fontLocation,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> enumValueMap,
com.android.ide.common.rendering.api.LayoutLog log)
Initializes the Layout Library object.
|
boolean |
isRtl(java.lang.String locale)
Returns true if the character orientation of the locale is right to left.
|
static LayoutLibrary |
load(com.android.ide.common.rendering.api.Bridge bridge,
java.lang.ClassLoader classLoader)
|
static LayoutLibrary |
load(java.lang.String layoutLibJarOsPath,
com.android.utils.ILogger log,
java.lang.String toolName)
Loads the layoutlib.jar file located at the given path and returns a
LayoutLibrary
object representing the result. |
com.android.ide.common.rendering.api.Result |
renderDrawable(com.android.ide.common.rendering.api.DrawableParams params)
Renders a Drawable.
|
boolean |
supports(com.android.ide.common.rendering.api.Capability capability)
Deprecated.
use
supports(int) |
boolean |
supports(int capability)
Returns whether the LayoutLibrary supports a given
Features . |
public static final java.lang.String CLASS_BRIDGE
public static final java.lang.String FN_ICU_JAR
public LoadStatus getStatus()
LoadStatus
of the loading of the layoutlib jar file.public java.lang.String getLoadMessage()
LoadStatus
. This is mostly used when
getStatus()
returns LoadStatus.FAILED
.public java.lang.ClassLoader getClassLoader()
public static LayoutLibrary load(com.android.ide.common.rendering.api.Bridge bridge, java.lang.ClassLoader classLoader)
public static LayoutLibrary load(java.lang.String layoutLibJarOsPath, com.android.utils.ILogger log, java.lang.String toolName)
LayoutLibrary
object representing the result.
If loading failed getStatus()
will reflect this, and mBridge
will
be null.
layoutLibJarOsPath
- the path of the jar filelog
- an optional log file.LayoutLibrary
object always.public int getApiLevel()
public int getRevision()
getApiLevel()
.getRevision()
@Deprecated public boolean supports(com.android.ide.common.rendering.api.Capability capability)
supports(int)
Capability
.Bridge.getCapabilities()
public boolean supports(int capability)
Features
.Bridge.supports(int)
public boolean init(java.util.Map<java.lang.String,java.lang.String> platformProperties, java.io.File fontLocation, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> enumValueMap, com.android.ide.common.rendering.api.LayoutLog log)
platformProperties
- The build properties for the platform.fontLocation
- the location of the fonts in the SDK target.enumValueMap
- map attrName ⇒ { map enumFlagName ⇒ Integer value }. This is typically
read from attrs.xml in the SDK target.log
- a LayoutLog
object. Can be null.public boolean dispose()
Bridge.dispose()
public com.android.ide.common.rendering.api.RenderSession createSession(com.android.ide.common.rendering.api.SessionParams params)
RenderSession
on which further actions can be taken.
Before taking further actions on the scene, it is recommended to use
supports(int)
to check what the scene can do.
RenderSession
object that contains the result of the scene creation and
first rendering or null if getStatus()
doesn't return LoadStatus.LOADED
.Bridge.createSession(SessionParams)
public com.android.ide.common.rendering.api.Result renderDrawable(com.android.ide.common.rendering.api.DrawableParams params)
Result.getData()
. It is of type BufferedImage
params
- the rendering parameters.public void clearCaches(java.lang.Object projectKey)
This cache contains bitmaps and nine patches that are loaded from the disk and reused until this method is called.
The cache is not configuration dependent and should only be cleared when a resource changes (at this time only bitmaps and 9 patches go into the cache).
projectKey
- the key for the project.Bridge.clearCaches(Object)
public com.android.ide.common.rendering.api.Result getViewParent(java.lang.Object viewObject)
viewObject
- the object for which to return the parent.Result
indicating the status of the action, and if success, the parent
object in Result.getData()
public com.android.ide.common.rendering.api.Result getViewIndex(java.lang.Object viewObject)
viewObject
- the object for which to return the index.Result
indicating the status of the action, and if success, the index in
the parent in Result.getData()
public boolean isRtl(java.lang.String locale)
locale
- The locale formatted as language-region