public class RenderSession
extends java.lang.Object
Bridge.createSession(SessionParams).
and can then be used for subsequent actions on the layout.| Modifier and Type | Class and Description |
|---|---|
static class |
RenderSession.TouchEventType
Type of touch event, a substitute for MotionEvent type, so that clients of layoutlib are kept
android platform agnostic.
|
| Constructor and Description |
|---|
RenderSession() |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Discards the layout.
|
boolean |
executeCallbacks(long nanos)
Requests execution of all the callbacks (used e.g.
|
java.util.Map<java.lang.Object,java.util.Map<ResourceReference,ResourceValue>> |
getDefaultNamespacedProperties()
Returns the map of View Cookie → properties (attribute name, attribute value) for all the
views that have a view cookie.
|
java.util.Map<java.lang.Object,ResourceReference> |
getDefaultNamespacedStyles()
Returns the map of View Cookie → default style for all the views that have a view cookie.
|
java.util.Map<java.lang.Object,java.lang.String> |
getDefaultStyles()
Deprecated.
|
java.awt.image.BufferedImage |
getImage()
Returns the rendering of the full layout.
|
Result |
getResult()
Returns the last operation result.
|
java.util.List<ViewInfo> |
getRootViews()
Returns the
ViewInfo objects for the top level views. |
java.util.List<ViewInfo> |
getSystemRootViews()
Returns the
ViewInfo objects for the system decor views, like the ActionBar. |
java.lang.Object |
getValidationData()
Returns validation data if it exists.
|
Result |
measure()
Does a measure pass and returns the result.
|
Result |
measure(long timeout)
Does a measure pass and returns the result.
|
Result |
render()
Re-renders the layout as-is.
|
Result |
render(long timeout)
Re-renders the layout as-is, with a given timeout in case other renderings are being done.
|
Result |
render(long timeout,
boolean forceMeasure)
Re-renders the layout as-is, with a given timeout in case other renderings are being done.
|
void |
setElapsedFrameTimeNanos(long nanos)
Sets the time for which the next frame will be selected.
|
void |
setSystemBootTimeNanos(long nanos)
Sets the system boot time in nanos.
|
void |
setSystemTimeNanos(long nanos)
Sets the current system time in nanos.
|
void |
triggerTouchEvent(RenderSession.TouchEventType type,
int x,
int y)
Inform RenderSession that a touch event happened.
|
public Result getResult()
public java.util.List<ViewInfo> getRootViews()
ViewInfo objects for the top level views.
It contains ViewInfo for only the views in the layout. For ViewInfo of the
System UI surrounding the layout use getSystemRootViews(). In most cases the list
will only contain one item. If the top level node is a merge though then it will
contain all the items under the merge tag.
This is reset to a new instance every time render() is called and can be
null if the call failed (and the method returned a Result with
Result.Status.ERROR_UNKNOWN or Result.Status.NOT_IMPLEMENTED.
This can be safely modified by the caller, but #getSystemRootViews and
#getRootViews share some view infos, so modifying one result can affect the other.
ViewInfo or null if there aren't any.getSystemRootViews()public java.util.List<ViewInfo> getSystemRootViews()
ViewInfo objects for the system decor views, like the ActionBar.
This is reset to a new instance every time render() is called and can be
null if the call failed, or there was no system decor.
This can be safely modified by the caller, but #getSystemRootViews and
#getRootViews share some view infos, so modifying one result can affect the other.
ViewInfo or null if there aren't any.public java.awt.image.BufferedImage getImage()
This is reset to a new instance every time render() is called and can be
null if the call failed (and the method returned a Result with
Result.Status.ERROR_UNKNOWN or Result.Status.NOT_IMPLEMENTED.
This can be safely modified by the caller.
public java.util.Map<java.lang.Object,java.util.Map<ResourceReference,ResourceValue>> getDefaultNamespacedProperties()
@Deprecated public java.util.Map<java.lang.Object,java.lang.String> getDefaultStyles()
public java.util.Map<java.lang.Object,ResourceReference> getDefaultNamespacedStyles()
public Result render()
getRootViews() and
getImage() to access the result of the rendering.
This is equivalent to calling render(SceneParams.DEFAULT_TIMEOUT)Result indicating the status of the action.public Result render(long timeout)
getRootViews() and
getImage() to access the result of the rendering.
The Bridge is only able to inflate or render one layout at a time. There
is an internal lock object whenever such an action occurs. The timeout parameter is used
when attempting to acquire the lock. If the timeout expires, the method will return
Result.Status.ERROR_TIMEOUT.timeout - timeout for the rendering, in milliseconds.Result indicating the status of the action.public Result measure()
This is equivalent to calling measure(RenderParams.DEFAULT_TIMEOUT)
The Bridge is only able to inflate or render one layout at a time. There
is an internal lock object whenever such an action occurs. The timeout parameter is used
when attempting to acquire the lock. If the timeout expires, the method will return
Result.Status.ERROR_TIMEOUT.
timeout - timeout for the measure call, in milliseconds.Result indicating the status of the action.public Result measure(long timeout)
The Bridge is only able to inflate or render one layout at a time. There
is an internal lock object whenever such an action occurs. The timeout parameter is used
when attempting to acquire the lock. If the timeout expires, the method will return
Result.Status.ERROR_TIMEOUT.
timeout - timeout for the measure call, in milliseconds.Result indicating the status of the action.public Result render(long timeout, boolean forceMeasure)
getRootViews() and
getImage() to access the result of the rendering.
This call also allows triggering a forced measure.
The Bridge is only able to inflate or render one layout at a time. There
is an internal lock object whenever such an action occurs. The timeout parameter is used
when attempting to acquire the lock. If the timeout expires, the method will return
Result.Status.ERROR_TIMEOUT.timeout - timeout for the rendering, in milliseconds.forceMeasure - force running measure for the layout.Result indicating the status of the action.public void setSystemTimeNanos(long nanos)
public void setSystemBootTimeNanos(long nanos)
public void setElapsedFrameTimeNanos(long nanos)
public boolean executeCallbacks(long nanos)
nanos - absolute time in nanoseconds to know what callbacks to execute.public void triggerTouchEvent(RenderSession.TouchEventType type, int x, int y)
type - type of touch event that happened.x - horizontal coordinate of a point where touch event happened.y - vertical coordinate of a point where touch event happened.public void dispose()
@Nullable public java.lang.Object getValidationData()