MotionScene
public class MotionScene
The information to transition between multiple ConstraintSets This Class is meant to be used from XML
Summary
Nested types |
|---|
public class MotionScene.TransitionTransition defines the interaction from one state to another. |
public class MotionScene.Transition.TransitionOnClick implements View.OnClickListener |
Constants |
|
|---|---|
static final int |
|
static final int |
|
static final int |
|
static final int |
UNSET = -1 |
Public constructors |
|---|
MotionScene(MotionLayout layout)Create a motion scene. |
Public methods |
|
|---|---|
void |
addOnClickListeners(MotionLayout motionLayout, int currentState)Add all on click listeners for the current state |
void |
addTransition(MotionScene.Transition transition)Add a transition to the motion scene. |
boolean |
applyViewTransition(Apply a view transition to the MotionController |
MotionScene.Transition |
bestTransitionFor(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 |
getConstraintSet(Context context, String id)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 |
getTransitionById(int id)Find the transition based on the id |
List<MotionScene.Transition> |
getTransitionsWithState(int stateId)Get all transitions that include this state |
boolean |
isViewTransitionEnabled(int id)Is this view transition enabled |
int |
Used at design time |
String |
lookUpConstraintName(int id)used at design time |
void |
removeTransition(MotionScene.Transition transition)Remove the transition with the matching id from the motion scene. |
void |
setConstraintSet(int id, ConstraintSet set)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 |
setTransition(MotionScene.Transition transition)Set the transition to be the current transition of the motion scene. |
static String |
Utility to strip the @id/ from an id |
boolean |
validateLayout(MotionLayout layout) |
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
Public constructors
MotionScene
public MotionScene(MotionLayout layout)
Create a motion scene.
| Parameters | |
|---|---|
MotionLayout layout |
Motion layout to which the scene will be set. |
Public methods
addOnClickListeners
public void addOnClickListeners(MotionLayout motionLayout, int currentState)
Add all on click listeners for the current state
| Parameters | |
|---|---|
MotionLayout motionLayout |
|
int currentState |
addTransition
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
public boolean applyViewTransition(
int viewTransitionId,
MotionController motionController
)
Apply a view transition to the MotionController
| Parameters | |
|---|---|
int viewTransitionId |
of viewTransition |
MotionController motionController |
| Returns | |
|---|---|
boolean |
bestTransitionFor
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 |
| Returns | |
|---|---|
MotionScene.Transition |
disableAutoTransition
public void disableAutoTransition(boolean disable)
this allow disabling autoTransitions to prevent design surface from being in undefined states
| Parameters | |
|---|---|
boolean disable |
enableViewTransition
public void enableViewTransition(int id, boolean enable)
Enable this viewTransition
| Parameters | |
|---|---|
int id |
of viewTransition |
boolean enable |
gatPathMotionArc
public int gatPathMotionArc()
The transition arc path mode
| Returns | |
|---|---|
int |
getConstraintSet
public ConstraintSet getConstraintSet(Context context, String id)
Get the constraintSet given the id
| Returns | |
|---|---|
ConstraintSet |
getConstraintSetIds
public int[] getConstraintSetIds()
Get the list of all Constraint Sets Know to the system
| Returns | |
|---|---|
int[] |
getDefinedTransitions
public ArrayList<MotionScene.Transition> getDefinedTransitions()
Get list of Transitions know to the system
| Returns | |
|---|---|
ArrayList<MotionScene.Transition> |
getDuration
public int getDuration()
Get Duration of the current transition.
| Returns | |
|---|---|
int |
duration in milliseconds |
getInterpolator
public Interpolator getInterpolator()
Get the interpolator define for the current Transition
| Returns | |
|---|---|
Interpolator |
getKeyFrames
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
public float getPathPercent(View view, int position)
Get the path percent (Non functional currently)
| Parameters | |
|---|---|
View view |
|
int position |
| Returns | |
|---|---|
float |
getStaggered
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
public MotionScene.Transition getTransitionById(int id)
Find the transition based on the id
| Parameters | |
|---|---|
int id |
| Returns | |
|---|---|
MotionScene.Transition |
getTransitionsWithState
public List<MotionScene.Transition> getTransitionsWithState(int stateId)
Get all transitions that include this state
| Parameters | |
|---|---|
int stateId |
| Returns | |
|---|---|
List<MotionScene.Transition> |
isViewTransitionEnabled
public boolean isViewTransitionEnabled(int id)
Is this view transition enabled
| Parameters | |
|---|---|
int id |
of viewTransition |
| Returns | |
|---|---|
boolean |
lookUpConstraintId
public int lookUpConstraintId(String id)
Used at design time
| Parameters | |
|---|---|
String id |
| Returns | |
|---|---|
int |
lookUpConstraintName
public String lookUpConstraintName(int id)
used at design time
| Returns | |
|---|---|
String |
removeTransition
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
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
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
public void setKeyframe(View view, int position, String name, Object value)
Set a keyFrame on the current Transition
setTransition
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. |
stripID
public static String stripID(String id)
Utility to strip the @id/ from an id
| Parameters | |
|---|---|
String id |
| Returns | |
|---|---|
String |
validateLayout
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 |