Package icyllis.modernui.transition

# Class Scene

java.lang.Object
icyllis.modernui.transition.Scene

public class Scene extends Object
A scene represents the collection of values that various properties in the View hierarchy will have when the scene is applied. A Scene can be configured to automatically run a Transition when it is applied, which will animate the various property changes that take place during the scene change.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Scene(ViewGroup sceneRoot)`
  Constructs a Scene with no information about how values will change when this scene is applied.
  `Scene(ViewGroup sceneRoot, View layout)`
  Constructs a Scene which, when entered, will remove any children from the sceneRoot container and add the layout object as a new child of that container.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `enter()`
  Enters this scene, which entails changing all values that are specified by this scene.
  `void`
  `exit()`
  Exits this scene, if it is the current scene on the scene's `scene root`.
  `static Scene`
  `getCurrentScene(ViewGroup sceneRoot)`
  Gets the current `Scene` set on the given ViewGroup.
  `ViewGroup`
  `getSceneRoot()`
  Gets the root of the scene, which is the root of the view hierarchy affected by changes due to this scene, and which will be animated when this scene is entered.
  `void`
  `setEnterAction(Runnable action)`
  Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well.
  `void`
  `setExitAction(Runnable action)`
  Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Scene

    public Scene(@Nonnull ViewGroup sceneRoot)
    Constructs a Scene with no information about how values will change when this scene is applied. This constructor might be used when a Scene is created with the intention of being dynamically configured, through setting `setEnterAction(Runnable)` and possibly `setExitAction(Runnable)`.
    Parameters:
      `sceneRoot` - The root of the hierarchy in which scene changes and transitions will take place.

  - ### Scene

    public Scene(@Nonnull ViewGroup sceneRoot, @Nonnull View layout)
    Constructs a Scene which, when entered, will remove any children from the sceneRoot container and add the layout object as a new child of that container.
    Parameters:
      `sceneRoot` - The root of the hierarchy in which scene changes and transitions will take place.
      `layout` - The view hierarchy of this scene, added as a child of sceneRoot when this scene is entered.

- ## Method Details

  - ### getSceneRoot

    @Nonnull public ViewGroup getSceneRoot()
    Gets the root of the scene, which is the root of the view hierarchy affected by changes due to this scene, and which will be animated when this scene is entered.
    Returns:
      The root of the view hierarchy affected by this scene.

  - ### exit

    public void exit()
    Exits this scene, if it is the current scene on the scene's `scene root`. The current scene is set when `entering` a scene. Exiting a scene runs the `exit action` if there is one.

  - ### enter

    public void enter()
    Enters this scene, which entails changing all values that are specified by this scene. These may be values associated with a layout view group or layout resource file which will now be added to the scene root, or it may be values changed by an `setEnterAction(Runnable)` enter action}, or a combination of the these. No transition will be run when the scene is entered. To get transition behavior in scene changes, use one of the methods in `TransitionManager` instead.

  - ### getCurrentScene

    @Nullable public static Scene getCurrentScene(@Nonnull ViewGroup sceneRoot)
    Gets the current `Scene` set on the given ViewGroup. A scene is set on a ViewGroup only if that ViewGroup is the scene root.
    Parameters:
      `sceneRoot` - The ViewGroup on which the current scene will be returned
    Returns:
      The current Scene set on this ViewGroup. A value of null indicates that no Scene is currently set.

  - ### setEnterAction

    public void setEnterAction(@Nullable Runnable action)
    Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well. An enter action will cause Scene to call back into application code to do anything else the application needs after transitions have captured pre-change values and after any other scene changes have been applied, such as the layout (if any) being added to the view hierarchy. After this method is called, Transitions will be played.
    Parameters:
      `action` - The runnable whose `run()` method will be called when this scene is entered
    See Also:
      - `setExitAction(Runnable)`
      - `Scene(ViewGroup)`

  - ### setExitAction

    public void setExitAction(@Nullable Runnable action)
    Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well. An exit action will cause Scene to call back into application code to do anything the application needs to do after applicable transitions have captured pre-change values, but before any other scene changes have been applied, such as the new layout (if any) being added to the view hierarchy. After this method is called, the next scene will be entered, including a call to `setEnterAction(Runnable)` if an enter action is set.
    See Also:
      - `setEnterAction(Runnable)`
      - `Scene(ViewGroup)`