MotionScene

public class MotionScene


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

Summary

Nested types

MotionScene.Transition

Transition defines the interaction from one state to another.

MotionScene.Transition.TransitionOnClick

Constants

static final @NonNull int
static final @NonNull int
static final @NonNull int

Public constructors

Create a motion scene.

Public methods

@NonNull void
addOnClickListeners(
    @NonNull MotionLayout motionLayout,
    @NonNull int currentState
)
@NonNull void

Add a transition to the motion scene.

@NonNull boolean
applyViewTransition(
    @NonNull int viewTransitionId,
    @NonNull MotionController motionController
)
@NonNull MotionScene.Transition
bestTransitionFor(
    @NonNull int currentState,
    @NonNull float dx,
    @NonNull float dy,
    @NonNull MotionEvent lastTouchDown
)
@NonNull void
disableAutoTransition(@NonNull boolean disable)

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

@NonNull void
enableViewTransition(@NonNull int id, @NonNull boolean enable)
@NonNull int
@NonNull ConstraintSet
@NonNull Array<@NonNull int>
@NonNull ArrayList<@NonNull MotionScene.Transition>
@NonNull int

Get Duration of the current transition.

@NonNull Interpolator
@NonNull void

provides the key frames & CycleFrames to the motion view to

@NonNull float
getPathPercent(@NonNull View view, @NonNull int position)
@NonNull float

Get the staggered value of the current transition.

@NonNull MotionScene.Transition
@NonNull List<@NonNull MotionScene.Transition>
@NonNull boolean
@NonNull int

Used at design time

@NonNull String

used at design time

@NonNull void

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

@NonNull void

Maps the Constraint set to the id.

@NonNull void
setDuration(@NonNull int duration)

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

@NonNull void
setKeyframe(
    @NonNull View view,
    @NonNull int position,
    @NonNull String name,
    @NonNull Object value
)
@NonNull void
setRtl(@NonNull boolean rtl)
@NonNull void

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

static @NonNull String
@NonNull boolean
@NonNull void

Constants

LAYOUT_HONOR_REQUEST

@NonNull
public static final @NonNull int LAYOUT_HONOR_REQUEST

LAYOUT_IGNORE_REQUEST

@NonNull
public static final @NonNull int LAYOUT_IGNORE_REQUEST

UNSET

@NonNull
public static final @NonNull int UNSET

Public constructors

MotionScene

public MotionScene(@NonNull MotionLayout layout)

Create a motion scene.

Parameters
@NonNull MotionLayout layout

Motion layout to which the scene will be set.

Public methods

addOnClickListeners

@NonNull
public void addOnClickListeners(
    @NonNull MotionLayout motionLayout,
    @NonNull int currentState
)

addTransition

@NonNull
public void addTransition(@NonNull 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

@NonNull
public boolean applyViewTransition(
    @NonNull int viewTransitionId,
    @NonNull MotionController motionController
)

bestTransitionFor

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

disableAutoTransition

@NonNull
public void disableAutoTransition(@NonNull boolean disable)

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

Parameters
@NonNull boolean disable

enableViewTransition

@NonNull
public void enableViewTransition(@NonNull int id, @NonNull boolean enable)

gatPathMotionArc

@NonNull
public int gatPathMotionArc()

getConstraintSet

@NonNull
public ConstraintSet getConstraintSet(@NonNull Context context, @NonNull String id)

getConstraintSetIds

@NonNull
public Array<@NonNull int> getConstraintSetIds()

getDuration

@NonNull
public int getDuration()

Get Duration of the current transition.

Returns
int

duration in milliseconds

getInterpolator

@NonNull
public Interpolator getInterpolator()

getKeyFrames

@NonNull
public void getKeyFrames(@NonNull MotionController motionController)

provides the key frames & CycleFrames to the motion view to

Parameters
@NonNull MotionController motionController

getPathPercent

@NonNull
public float getPathPercent(@NonNull View view, @NonNull int position)

getStaggered

@NonNull
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

@NonNull
public MotionScene.Transition getTransitionById(@NonNull int id)

getTransitionsWithState

@NonNull
public List<@NonNull MotionScene.TransitiongetTransitionsWithState(@NonNull int stateId)

isViewTransitionEnabled

@NonNull
public boolean isViewTransitionEnabled(@NonNull int id)

lookUpConstraintId

@NonNull
public int lookUpConstraintId(@NonNull String id)

Used at design time

Parameters
@NonNull String id
Returns
int

lookUpConstraintName

@NonNull
public String lookUpConstraintName(@NonNull int id)

used at design time

Returns
String

removeTransition

@NonNull
public void removeTransition(@NonNull 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

@NonNull
public void setConstraintSet(@NonNull int id, @NonNull ConstraintSet set)

Maps the Constraint set to the id.

Parameters
@NonNull int id

- unique id to represent the ConstraintSet

@NonNull ConstraintSet set

- ConstraintSet to be represented with the id.

setDuration

@NonNull
public void setDuration(@NonNull int duration)

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

Parameters
@NonNull int duration

in milliseconds

setKeyframe

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

setRtl

@NonNull
public void setRtl(@NonNull boolean rtl)

setTransition

@NonNull
public void setTransition(@NonNull MotionScene.Transition transition)

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

Parameters
@NonNull MotionScene.Transition transition

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

stripID

@NonNull
public static String stripID(@NonNull String id)

validateLayout

@NonNull
public boolean validateLayout(@NonNull MotionLayout layout)
Returns
boolean

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

viewTransition

@NonNull
public void viewTransition(@NonNull int id, @NonNull Array<@NonNull View> view)