public class RenderSession
extends java.lang.Object
Bridge.createSession(SessionParams)
.
and can then be used for subsequent actions on the layout.Constructor and Description |
---|
RenderSession() |
Modifier and Type | Method and Description |
---|---|
Result |
animate(java.lang.Object targetObject,
java.lang.String animationName,
boolean isFrameworkAnimation,
IAnimationListener listener)
Starts playing an given animation on a given object.
|
void |
dispose()
Discards the layout.
|
java.util.Map<java.lang.Object,PropertiesMap> |
getDefaultProperties()
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.String,java.lang.String> |
getDefaultProperties(java.lang.Object viewObject)
Deprecated.
|
java.awt.image.BufferedImage |
getImage()
Returns the rendering of the full layout.
|
Result |
getProperty(java.lang.Object objectView,
java.lang.String propertyName)
returns the value of a given property on a given object.
|
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. |
Result |
insertChild(java.lang.Object parentView,
ILayoutPullParser childXml,
int index,
IAnimationListener listener)
Inserts a new child in a ViewGroup object, and renders the result.
|
boolean |
isAlphaChannelImage()
Returns true if the current image alpha channel is relevant.
|
Result |
measure()
Does a measure pass and returns the result.
|
Result |
measure(long timeout)
Does a measure pass and returns the result.
|
Result |
moveChild(java.lang.Object parentView,
java.lang.Object childView,
int index,
java.util.Map<java.lang.String,java.lang.String> layoutParams,
IAnimationListener listener)
Move a new child to a different ViewGroup object.
|
Result |
removeChild(java.lang.Object childView,
IAnimationListener listener)
Removes a child from a ViewGroup object.
|
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.
|
Result |
setProperty(java.lang.Object objectView,
java.lang.String propertyName,
java.lang.String propertyValue)
Sets the value of a given property on a given object.
|
void |
setSystemBootTimeNanos(long nanos)
Sets the system boot time in nanos.
|
void |
setSystemTimeNanos(long nanos)
Sets the current system time in nanos.
|
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 boolean isAlphaChannelImage()
@Deprecated public java.util.Map<java.lang.String,java.lang.String> getDefaultProperties(java.lang.Object viewObject)
getDefaultProperties()
viewObject
- the view object.public java.util.Map<java.lang.Object,PropertiesMap> getDefaultProperties()
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 Result setProperty(java.lang.Object objectView, java.lang.String propertyName, java.lang.String propertyValue)
This does nothing more than change the property. To render the scene in its new state, a
call to render()
is required.
Any amount of actions can be taken on the scene before render()
is called.
objectView
- propertyName
- propertyValue
- Result
indicating the status of the action.java.lang.IllegalArgumentException
- if the view object is not an android.view.Viewpublic Result getProperty(java.lang.Object objectView, java.lang.String propertyName)
This returns a Result
object. If the operation of querying the object for its
property was successful (check Result.isSuccess()
), then the property value
is set in the result and can be accessed through Result.getData()
.
objectView
- propertyName
- Result
indicating the status of the action.java.lang.IllegalArgumentException
- if the view object is not an android.view.Viewpublic Result insertChild(java.lang.Object parentView, ILayoutPullParser childXml, int index, IAnimationListener listener)
The child is first inflated and then added to its new parent, at the given index position. If the index is -1 then the child is added at the end of the parent.
If an animation listener is passed then the rendering is done asynchronously and the result is sent to the listener. If the listener is null, then the rendering is done synchronously.
The child stays in the view hierarchy after the rendering is done. To remove it call
removeChild(Object, IAnimationListener)
The returned Result
object will contain the android.view.View object for
the newly inflated child. It is accessible through Result.getData()
.
parentView
- the parent View object to receive the new child.childXml
- an ILayoutPullParser
containing the content of the new child,
including ViewGroup.LayoutParams attributes.index
- the index at which position to add the new child into the parent. -1 means at
the end.listener
- an optional IAnimationListener
.Result
indicating the status of the action.public Result moveChild(java.lang.Object parentView, java.lang.Object childView, int index, java.util.Map<java.lang.String,java.lang.String> layoutParams, IAnimationListener listener)
The child is first removed from its current parent, and then added to its new parent, at the given index position. In case the parentView is the current parent of childView then the index must be the value with the childView removed from its parent. If the index is -1 then the child is added at the end of the parent.
If an animation listener is passed then the rendering is done asynchronously and the result is sent to the listener. If the listener is null, then the rendering is done synchronously.
The child stays in the view hierarchy after the rendering is done. To remove it call
removeChild(Object, IAnimationListener)
The returned Result
object will contain the android.view.ViewGroup.LayoutParams
object created from the layoutParams map if it was non null
.
parentView
- the parent View object to receive the child. Can be the current parent
already.childView
- the view to move.index
- the index at which position to add the new child into the parent. -1 means at
the end.layoutParams
- an optional map of new ViewGroup.LayoutParams attribute. If non null,
then the current layout params of the view will be removed and a new one will
be inflated and set with the content of the map.listener
- an optional IAnimationListener
.Result
indicating the status of the action.public Result removeChild(java.lang.Object childView, IAnimationListener listener)
This does nothing more than change the layout. To render the scene in its new state, a
call to render()
is required.
Any amount of actions can be taken on the scene before render()
is called.
childView
- the view object to remove from its parentlistener
- an optional IAnimationListener
.Result
indicating the status of the action.public Result animate(java.lang.Object targetObject, java.lang.String animationName, boolean isFrameworkAnimation, IAnimationListener listener)
The animation playback is asynchronous and the rendered frame is sent vi the listener.
targetObject
- the view object to animateanimationName
- the name of the animation (res/anim) to play.listener
- the listener callback.Result
indicating the status of the action.public void setSystemTimeNanos(long nanos)
Calls to this method must check that layoutlib supports Features.SYSTEM_TIME
public void setSystemBootTimeNanos(long nanos)
Calls to this method must check that layoutlib supports Features.SYSTEM_TIME
public void setElapsedFrameTimeNanos(long nanos)
Calls to this method must check that layoutlib supports Features.SYSTEM_TIME
public void dispose()