com.android.ide.common.rendering.api
Class Bridge

java.lang.Object
  extended by com.android.ide.common.rendering.api.Bridge

public abstract class Bridge
extends java.lang.Object

Entry point of the Layout Library. Extensions of this class provide a method to compute and render a layout.


Field Summary
static int API_CURRENT
           
 
Constructor Summary
Bridge()
           
 
Method Summary
 void clearCaches(java.lang.Object projectKey)
          Clears the resource cache for a specific project.
 RenderSession createSession(SessionParams params)
          Starts a layout session by inflating and rendering it.
 boolean dispose()
          Prepares the layoutlib to unloaded.
abstract  int getApiLevel()
          Returns the API level of the layout library.
 java.util.EnumSet<Capability> getCapabilities()
          Deprecated. use supports(int)
 int getRevision()
          Returns the revision of the library inside a given (layoutlib) API level.
 Result getViewBaseline(java.lang.Object viewObject)
          Deprecated. use the extended ViewInfo.
 Result getViewIndex(java.lang.Object viewObject)
          Utility method returning the index of a given view in its parent.
 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, LayoutLog log)
          Initializes the Bridge object.
 boolean isRtl(java.lang.String locale)
          Returns true if the character orientation of the locale is right to left.
 Result renderDrawable(DrawableParams params)
          Renders a Drawable.
 boolean supports(int feature)
          Returns true if the layout library supports the given feature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

API_CURRENT

public static final int API_CURRENT
See Also:
Constant Field Values
Constructor Detail

Bridge

public Bridge()
Method Detail

getApiLevel

public abstract int getApiLevel()
Returns the API level of the layout library.

While no methods will ever be removed, some may become deprecated, and some new ones will appear.

All Layout libraries based on Bridge return at minimum an API level of 5.


getRevision

public int getRevision()
Returns the revision of the library inside a given (layoutlib) API level. The true revision number of the library is getApiLevel().getRevision()


getCapabilities

@Deprecated
public java.util.EnumSet<Capability> getCapabilities()
Deprecated. use supports(int)

Returns an EnumSet of the supported Capability.

Returns:
an EnumSet with the supported capabilities.

supports

public boolean supports(int feature)
Returns true if the layout library supports the given feature.

See Also:
Features

init

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,
                    LayoutLog log)
Initializes the Bridge object.

Parameters:
platformProperties - The build properties for the platform.
fontLocation - the location of the fonts.
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.
Returns:
true if success.

dispose

public boolean dispose()
Prepares the layoutlib to unloaded.


createSession

public RenderSession createSession(SessionParams params)
Starts a layout session by inflating and rendering it. The method returns a RenderSession on which further actions can be taken.

Returns:
a new RenderSession object that contains the result of the scene creation and first rendering.

renderDrawable

public Result renderDrawable(DrawableParams params)
Renders a Drawable. If the rendering is successful, the result image is accessible through Result.getData(). It is of type BufferedImage

Parameters:
params - the rendering parameters.
Returns:
the result of the action.

clearCaches

public void clearCaches(java.lang.Object projectKey)
Clears the resource cache for a specific project.

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).

The project key provided must be similar to the one passed in RenderParams.

Parameters:
projectKey - the key for the project.

getViewParent

public Result getViewParent(java.lang.Object viewObject)
Utility method returning the parent of a given view object.

Parameters:
viewObject - the object for which to return the parent.
Returns:
a Result indicating the status of the action, and if success, the parent object in Result.getData()

getViewIndex

public Result getViewIndex(java.lang.Object viewObject)
Utility method returning the index of a given view in its parent.

Parameters:
viewObject - the object for which to return the index.
Returns:
a Result indicating the status of the action, and if success, the index in the parent in Result.getData()

isRtl

public boolean isRtl(java.lang.String locale)
Returns true if the character orientation of the locale is right to left.

Parameters:
locale - The locale formatted as language-region
Returns:
true if the locale is right to left.

getViewBaseline

@Deprecated
public Result getViewBaseline(java.lang.Object viewObject)
Deprecated. use the extended ViewInfo.

Utility method returning the baseline value for a given view object. This basically returns View.getBaseline().

Parameters:
viewObject - the object for which to return the index.
Returns:
the baseline value or -1 if not applicable to the view object or if this layout library does not implement this method.