public class MotionScene


The information to transition between multiple ConstraintSets This Class is meant to be used from XML

Summary

Nested types

Transition defines the interaction from one state to another.

Constants

static final int
static final int
static final int
static final int
UNSET = -1

Public constructors

Create a motion scene.

Public methods

void
addOnClickListeners(MotionLayout motionLayout, int currentState)

Add all on click listeners for the current state

void

Add a transition to the motion scene.

boolean
applyViewTransition(
    int viewTransitionId,
    MotionController motionController
)

Apply a view transition to the MotionController

MotionScene.Transition
bestTransitionFor(
    int currentState,
    float dx,
    float dy,
    MotionEvent lastTouchDown
)

Find the best transition for the motion

void
disableAutoTransition(boolean disable)

this allow disabling autoTransitions to prevent design surface from being in undefined states

void
enableViewTransition(int id, boolean enable)

Enable this viewTransition

int

The transition arc path mode

ConstraintSet

Get the constraintSet given the id

int[]

Get the list of all Constraint Sets Know to the system

ArrayList<MotionScene.Transition>

Get list of Transitions know to the system

int

Get Duration of the current transition.

Interpolator

Get the interpolator define for the current Transition

void
getKeyFrames(MotionController motionController)

provides the key frames &CycleFrames to the motion view to

int[]
getMatchingStateLabels(String[] types)

Get the id's of all constraintSets with the matching types

float
getPathPercent(View view, int position)

Get the path percent (Non functional currently)

float

Get the staggered value of the current transition.

MotionScene.Transition

Find the transition based on the id

List<MotionScene.Transition>

Get all transitions that include this state

boolean

Is this view transition enabled

int

Used at design time

String

used at design time

void

Remove the transition with the matching id from the motion scene.

void

Maps the Constraint set to the id.

void
setDuration(int duration)

Sets the duration of the current transition or the default if there is no current transition

void
setKeyframe(View view, int position, String name, Object value)

Set a keyFrame on the current Transition

void
setRtl(boolean rtl)

Set Right to left

void

Set the transition to be the current transition of the motion scene.

static String

Utility to strip the @id/ from an id

boolean
void
viewTransition(int id, View[] view)

Apply the viewTransition on the list of views

Protected methods

void
onLayout(boolean changed, int left, int top, int right, int bottom)

Constants

LAYOUT_CALL_MEASURE

Added in 2.2.0-alpha13
public static final int LAYOUT_CALL_MEASURE = 2

LAYOUT_HONOR_REQUEST

Added in 2.2.0-alpha13
public static final int LAYOUT_HONOR_REQUEST = 1

LAYOUT_IGNORE_REQUEST

Added in 2.2.0-alpha13
public static final int LAYOUT_IGNORE_REQUEST = 0

UNSET

Added in 2.2.0-alpha13
public static final int UNSET = -1

Public constructors

MotionScene

Added in 2.2.0-alpha13
public MotionScene(MotionLayout layout)

Create a motion scene.

Parameters
MotionLayout layout

Motion layout to which the scene will be set.

Public methods

addOnClickListeners

Added in 2.2.0-alpha13
public void addOnClickListeners(MotionLayout motionLayout, int currentState)

Add all on click listeners for the current state

Parameters
MotionLayout motionLayout
int currentState

addTransition

Added in 2.2.0-alpha13
public void addTransition(MotionScene.Transition transition)

Add a transition to the motion scene. If a transition with the same id already exists in the scene, the new transition will replace the existing one.

Throws
java.lang.IllegalArgumentException

if the transition does not have an id.

applyViewTransition

Added in 2.2.0-alpha13
public boolean applyViewTransition(
    int viewTransitionId,
    MotionController motionController
)

Apply a view transition to the MotionController

Parameters
int viewTransitionId

of viewTransition

MotionController motionController
Returns
boolean

bestTransitionFor

Added in 2.2.0-alpha13
public MotionScene.Transition bestTransitionFor(
    int currentState,
    float dx,
    float dy,
    MotionEvent lastTouchDown
)

Find the best transition for the motion

Parameters
int currentState
float dx

drag delta x

float dy

drag delta y

MotionEvent lastTouchDown

disableAutoTransition

Added in 2.2.0-alpha13
public void disableAutoTransition(boolean disable)

this allow disabling autoTransitions to prevent design surface from being in undefined states

Parameters
boolean disable

enableViewTransition

Added in 2.2.0-alpha13
public void enableViewTransition(int id, boolean enable)

Enable this viewTransition

Parameters
int id

of viewTransition

boolean enable

gatPathMotionArc

Added in 2.2.0-alpha13
public int gatPathMotionArc()

The transition arc path mode

Returns
int

getConstraintSet

Added in 2.2.0-alpha13
public ConstraintSet getConstraintSet(Context context, String id)

Get the constraintSet given the id

Parameters
Context context
String id
Returns
ConstraintSet

getConstraintSetIds

Added in 2.2.0-alpha13
public int[] getConstraintSetIds()

Get the list of all Constraint Sets Know to the system

Returns
int[]

getDefinedTransitions

Added in 2.2.0-alpha13
public ArrayList<MotionScene.TransitiongetDefinedTransitions()

Get list of Transitions know to the system

getDuration

Added in 2.2.0-alpha13
public int getDuration()

Get Duration of the current transition.

Returns
int

duration in milliseconds

getInterpolator

Added in 2.2.0-alpha13
public Interpolator getInterpolator()

Get the interpolator define for the current Transition

Returns
Interpolator

getKeyFrames

Added in 2.2.0-alpha13
public void getKeyFrames(MotionController motionController)

provides the key frames &CycleFrames to the motion view to

Parameters
MotionController motionController

getMatchingStateLabels

public int[] getMatchingStateLabels(String[] types)

Get the id's of all constraintSets with the matching types

Returns
int[]

getPathPercent

Added in 2.2.0-alpha13
public float getPathPercent(View view, int position)

Get the path percent (Non functional currently)

Parameters
View view
int position
Returns
float

getStaggered

Added in 2.2.0-alpha13
public float getStaggered()

Get the staggered value of the current transition. Will default to 0 staggered if there is no current transition.

Returns
float

getTransitionById

Added in 2.2.0-alpha13
public MotionScene.Transition getTransitionById(int id)

Find the transition based on the id

Parameters
int id

getTransitionsWithState

Added in 2.2.0-alpha13
public List<MotionScene.TransitiongetTransitionsWithState(int stateId)

Get all transitions that include this state

Parameters
int stateId

isViewTransitionEnabled

Added in 2.2.0-alpha13
public boolean isViewTransitionEnabled(int id)

Is this view transition enabled

Parameters
int id

of viewTransition

Returns
boolean

lookUpConstraintId

Added in 2.2.0-alpha13
public int lookUpConstraintId(String id)

Used at design time

Parameters
String id
Returns
int

lookUpConstraintName

Added in 2.2.0-alpha13
public String lookUpConstraintName(int id)

used at design time

Returns
String

removeTransition

Added in 2.2.0-alpha13
public void removeTransition(MotionScene.Transition transition)

Remove the transition with the matching id from the motion scene. If no matching transition is found, it does nothing.

Throws
java.lang.IllegalArgumentException

if the transition does not have an id.

setConstraintSet

Added in 2.2.0-alpha13
public void setConstraintSet(int id, ConstraintSet set)

Maps the Constraint set to the id.

Parameters
int id

- unique id to represent the ConstraintSet

ConstraintSet set

- ConstraintSet to be represented with the id.

setDuration

Added in 2.2.0-alpha13
public void setDuration(int duration)

Sets the duration of the current transition or the default if there is no current transition

Parameters
int duration

in milliseconds

setKeyframe

Added in 2.2.0-alpha13
public void setKeyframe(View view, int position, String name, Object value)

Set a keyFrame on the current Transition

Parameters
View view
int position
String name
Object value

setRtl

Added in 2.2.0-alpha13
public void setRtl(boolean rtl)

Set Right to left

Parameters
boolean rtl

setTransition

Added in 2.2.0-alpha13
public void setTransition(MotionScene.Transition transition)

Set the transition to be the current transition of the motion scene.

Parameters
MotionScene.Transition transition

a transition to be set. The transition must exist within the motion scene. (e.g. addTransition)

stripID

Added in 2.2.0-alpha13
public static String stripID(String id)

Utility to strip the @id/ from an id

Parameters
String id
Returns
String

validateLayout

Added in 2.2.0-alpha13
public boolean validateLayout(MotionLayout layout)
Returns
boolean

true if the layout is valid for the scene. False otherwise. Use it for the debugging purposes.

viewTransition

public void viewTransition(int id, View[] view)

Apply the viewTransition on the list of views

Parameters
int id
View[] view

Protected methods

onLayout

Added in 2.2.0-alpha13
protected void onLayout(boolean changed, int left, int top, int right, int bottom)