Class DynamicMotion
java.lang.Object
com.pranavpandey.android.dynamic.support.motion.DynamicMotion
Helper class to perform various animations.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
Constant values for the animation duration.static @interface
Constant values for the view properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
beginDelayedTransition
(ViewGroup sceneRoot) UseTransitionManager
to begin delayed transition according to the motion duration.void
beginDelayedTransition
(ViewGroup sceneRoot, Transition transition) UseTransitionManager
to begin delayed transition according to the motion duration.floatWithAlpha
(View target, long startDelay, Property<View, Float> property, float from, float to, float alphaFrom, float alphaTo) Returns an animator set with view property and alpha animators.floatWithAlpha
(View target, Property<View, Float> property, float from, float to, float alphaFrom, float alphaTo) Returns an animator set with view property and alpha animators.long
Get the current motion duration.static DynamicMotion
Retrieves the singleton instance ofDynamicMotion
.boolean
isMotion()
Checks whether the motion is enabled.Sets the default motion duration.setDuration
(long duration) Sets the motion duration.setMotion
(boolean motion) Sets the motion, either enable or disable.<T> T
withDuration
(T transition) Returns the transition with the default duration.<T> T
withDuration
(T transition, long duration) Returns the transition with the specified duration.<T> T
withInterpolator
(T transition, Interpolator interpolator) Returns the transition with the specified interpolator.<T> T
withStartDelay
(T transition) Returns the transition with the default start delay.<T> T
withStartDelay
(T transition, long startDelay) Returns the transition with the specified start delay.
-
Method Details
-
getInstance
Retrieves the singleton instance ofDynamicMotion
.Must be called before accessing the public methods.
- Returns:
- The singleton instance of
DynamicMotion
.
-
isMotion
public boolean isMotion()Checks whether the motion is enabled.- Returns:
true
if the motion is enabled.
-
setMotion
Sets the motion, either enable or disable.- Parameters:
motion
-true
to enable the motion.- Returns:
- The
DynamicMotion
object to allow for chaining of calls to set methods.
-
getDuration
public long getDuration()Get the current motion duration.- Returns:
- The current motion duration.
-
setDuration
Sets the motion duration.- Parameters:
duration
- The motion duration to be set.Use
0
orDynamicMotion.Duration.NO
to disable all the motion.- Returns:
- The
DynamicMotion
object to allow for chaining of calls to set methods.
-
setDuration
Sets the default motion duration.- Returns:
- The
DynamicMotion
object to allow for chaining of calls to set methods. - See Also:
-
floatWithAlpha
@NonNull public AnimatorSet floatWithAlpha(@Nullable View target, long startDelay, @NonNull Property<View, Float> property, float from, float to, @FloatRange(from=0.0,to=1.0) float alphaFrom, @FloatRange(from=0.0,to=1.0) float alphaTo) Returns an animator set with view property and alpha animators.- Parameters:
target
- The target view to be animated.startDelay
- The start delay for the animation.property
- The view property to be animated.from
- The initial value fo the view property.to
- The final value of the view property.alphaFrom
- The initial value of the view alpha.alphaTo
- The final value of the view alpha.- Returns:
- The animator set with view property and alpha animators.
- See Also:
-
floatWithAlpha
@NonNull public AnimatorSet floatWithAlpha(@Nullable View target, @NonNull Property<View, Float> property, float from, float to, @FloatRange(from=0.0,to=1.0) float alphaFrom, @FloatRange(from=0.0,to=1.0) float alphaTo) Returns an animator set with view property and alpha animators.- Parameters:
target
- The target view to be animated.property
- The view property to be animated.from
- The initial value fo the view property.to
- The final value of the view property.alphaFrom
- The initial value of the view alpha.alphaTo
- The final value of the view alpha.- Returns:
- The animator set with view property and alpha animators.
- See Also:
-
withDuration
Returns the transition with the specified duration.- Type Parameters:
T
- The type of the transition.- Parameters:
transition
- The transition to used.duration
- The duration to be set.- Returns:
- The transition with the specified duration.
-
withDuration
Returns the transition with the default duration.- Type Parameters:
T
- The type of the transition.- Parameters:
transition
- The transition to used.- Returns:
- The transition with the default duration.
- See Also:
-
withStartDelay
Returns the transition with the specified start delay.- Type Parameters:
T
- The type of the transition.- Parameters:
transition
- The transition to used.startDelay
- The start delay to be set.- Returns:
- The transition with the specified start delay.
-
withStartDelay
Returns the transition with the default start delay.- Type Parameters:
T
- The type of the transition.- Parameters:
transition
- The transition to used.- Returns:
- The transition with the
DynamicMotion.Duration.SHORTER
delay. - See Also:
-
withInterpolator
@Nullable public <T> T withInterpolator(@Nullable T transition, @Nullable Interpolator interpolator) Returns the transition with the specified interpolator.- Type Parameters:
T
- The type of the transition.- Parameters:
transition
- The transition to used.interpolator
- The interpolator to be set.- Returns:
- The transition with the specified interpolator.
-
beginDelayedTransition
UseTransitionManager
to begin delayed transition according to the motion duration.- Parameters:
sceneRoot
- The scene root to be used.transition
- The transition to be used.- See Also:
-
beginDelayedTransition
UseTransitionManager
to begin delayed transition according to the motion duration.- Parameters:
sceneRoot
- The scene root to be used.- See Also:
-