Class BaseAdditiveAnimator<T extends BaseAdditiveAnimator,​V>

  • Type Parameters:
    T - This generic should be instantiated with a concrete subclass of BaseAdditiveAnimator. It is used to access the builder methods across hierarchies. Example:

    public class MyViewAnimator extends BaseAdditiveAnimator<MyViewAnimator, View>

    V - The type of object to be animated.
    Direct Known Subclasses:
    AdditiveObjectAnimator, SubclassableAdditiveViewAnimator

    public abstract class BaseAdditiveAnimator<T extends BaseAdditiveAnimator,​V>
    extends AnimationSequence
    This is the base class which provides access to all non-specific animation creation methods such as creation, timing and chaining of additive animations. Subclasses should provide builder methods which create specific animations (see SubclassableAdditiveViewAnimator for examples).
    • Field Detail

      • mCurrentTarget

        protected V mCurrentTarget
      • mRunningAnimationsManager

        @Nullable
        protected at.wirecube.additiveanimations.additive_animator.RunningAnimationsManager<V> mRunningAnimationsManager
      • mAnimationAccumulator

        protected at.wirecube.additiveanimations.additive_animator.AdditiveAnimationAccumulator mAnimationAccumulator
      • mCurrentCustomInterpolator

        protected TimeInterpolator mCurrentCustomInterpolator
      • mAnimatorGroup

        protected at.wirecube.additiveanimations.additive_animator.AdditiveAnimatorGroup mAnimatorGroup
        Indicates which animation group this animator belongs to. An animation group is a set of animators which have different targets, but share the same animations. An example would be: new AdditiveAnimator().targets(v1, v2).alpha(0).start(); In this case, v1 and v2 have different AdditiveAnimator instances, but share the same animations (alpha = 0). Animation groups are inherited with then() chaining. All animators in the group can have different starting offsets when using the targets(views, stagger) method.
    • Constructor Detail

      • BaseAdditiveAnimator

        public BaseAdditiveAnimator()
    • Method Detail

      • self

        protected T self()
      • getRunningAnimationsManager

        @NonNull
        protected final at.wirecube.additiveanimations.additive_animator.RunningAnimationsManager<V> getRunningAnimationsManager()
      • cancelAnimationsForObject

        public static void cancelAnimationsForObject​(Object target)
      • cancelAnimationsForObjects

        public static void cancelAnimationsForObjects​(Object... targets)
      • cancelAnimationsInCollection

        public static <T extends Collection<? extends Object>> void cancelAnimationsInCollection​(T targets)
      • cancelAnimation

        public static void cancelAnimation​(Object target,
                                           String animationTag)
      • cancelAnimation

        public static void cancelAnimation​(List<Object> targets,
                                           String animationTag)
      • cancelAnimation

        public static <T> void cancelAnimation​(T target,
                                               Property<T,​Float> property)
      • initValueAnimatorIfNeeded

        protected void initValueAnimatorIfNeeded()
      • addTarget

        @Deprecated
        public T addTarget​(V v)
        Deprecated.
        Use #target(V) instead.
        Old API for #target(V), which should be used instead.
      • getTargetPropertyValue

        public float getTargetPropertyValue​(Property<V,​Float> property)
        Finds the last target value of the property with the given name, or returns `property.get()` if the property isn't animating at the moment.
      • getTargetPropertyValue

        public Float getTargetPropertyValue​(String propertyName)
        Finds the last target value of the property with the given name, if it was ever animated. This method can return null if the value hasn't been animated or the animation is already done.
      • getCurrentPropertyValue

        public abstract Float getCurrentPropertyValue​(String propertyName)
        Returns the actual value of the animation target with the given name.
      • getQueuedPropertyValue

        protected Float getQueuedPropertyValue​(String propertyName)
        Returns the last value that was queued for animation whose animation has not yet started. This method is for internal use only (keeping track of chained `animateBy` calls).
      • onApplyChanges

        public abstract void onApplyChanges()
        This method will be called when the current frame has been calculated. Override this method in a subclass to trigger a layout of your view/canvas/custom object.
      • applyCustomProperties

        protected void applyCustomProperties​(Map<String,​Float> tempProperties,
                                             V target)
      • getCurrentTarget

        protected V getCurrentTarget()
      • animate

        protected final T animate​(AdditiveAnimation animation,
                                  boolean propagateToParentAnimators)
        Handles some bookkeeping for adding the given animation to the list of running animations. You have to call this method to add animations.
        Parameters:
        animation - The animation to be added to the running animations.
        propagateToParentAnimators - Whether or not this animation will be propagated to the parent animators. You can set it to `false` if you propagate the animation manually to the other animators in this group. If you fail to propagate the animation correctly, targets(List, long) will not work with that animation. (If you don't know what that means, you should probably just pass `true` and have the base implementation take care of it.)
      • animate

        protected final T animate​(Property<V,​Float> property,
                                  float target)
      • animatePropertyBy

        protected final T animatePropertyBy​(Property<V,​Float> property,
                                            float by,
                                            boolean byValueCanBeUsedByParentAnimators)
        TODO: documentation of byValueCanBeUsedByParentAnimators
      • property

        public T property​(float target,
                          FloatProperty<V> customProperty)
      • property

        public T property​(float target,
                          FloatProperty<V> customProperty,
                          boolean by)
      • apply

        public static <V> void apply​(AnimationAction<V> action,
                                     V... targets)
        Immediately applies the animation action to the given targets. (similar to Butterknife's `apply' method).
      • setDefaultDuration

        public static void setDefaultDuration​(long defaultDuration)
        Globally sets the default animation duration to use for all AdditiveAnimator instances. You can override this by calling setDuration(long) on a specific instance.
      • setDefaultInterpolator

        public static void setDefaultInterpolator​(TimeInterpolator interpolator)
        Globally sets the default interpolator to use for all AdditiveAnimator instances. You can override this by calling setInterpolator(TimeInterpolator) on a specific instance.
      • target

        public T target​(V v)
        Sets the current animation target. You can change the animation target multiple times before calling start():

        new AdditiveAnimator().target(view1).x(100).target(view2).y(200).start()

        If you want to animate the same property of multiple views, use targets(Object[]) or targets(List, long)

      • targets

        public T targets​(@NonNull
                         V... vs)
        Used to animate the same property of multiple views. This is a convenience method which simply creates a series of animators which will start simultaneously. Example:

        new AdditiveAnimator().targets(textView, button).alpha(0).start()

      • targets

        public T targets​(@NonNull
                         List<V> vs)
        Used to animate the same property of multiple views. This is a convenience method which simply creates a series of animators which will start simultaneously. Example:

        new AdditiveAnimator().targets(myViewList).alpha(0).start()

      • targets

        public T targets​(@NonNull
                         List<V> vs,
                         long stagger)
        Used to animate the same property of multiple views, with a delay before each element. This is a convenience method which simply creates a series of animators which will start with `stagger` offset after each other. Example:

        new AdditiveAnimator().targets(Arrays.asList(textView, button), 100).translationYBy(100).alpha(0).start()

      • addStartAction

        public T addStartAction​(Runnable r)
      • setStartDelay

        public T setStartDelay​(long startDelay)
      • setDuration

        public T setDuration​(long duration)
      • switchDuration

        public T switchDuration​(long durationMillis)
      • switchToDefaultInterpolator

        public T switchToDefaultInterpolator()
      • setRepeatCount

        public T setRepeatCount​(int repeatCount)
      • setRepeatMode

        public T setRepeatMode​(int repeatMode)
      • switchInterpolator

        public T switchInterpolator​(TimeInterpolator newInterpolator)
        Switches to the given interpolator only for all following animations. This is different from `setInterpolator` in that it doesn't apply to animations that were created before calling this method. Calling `setInterpolator` after calling this method at least once will behave the same as calling `switchInterpolator` to prevent accidentally overriding the effects of `switchInterpolator`.
      • newInstance

        protected abstract T newInstance()
        Factory method for creation of subclass instances. Override to use all of the advanced features with your custom subclass.
      • then

        public T then()
        Creates a new animator configured to start after the current animator with the current target that was configured with this animator.
      • thenWithDelay

        public T thenWithDelay​(long delay)
        Creates a new animator configured to start after delay milliseconds from now with the last used target and interpolator.
      • thenDelayAfterEnd

        public T thenDelayAfterEnd​(long delayAfterEnd)
        Creates a new animator configured to start after delayAfterEnd milliseconds after the previous animation has ended with the last used target and interpolator.
      • thenBeforeEnd

        public T thenBeforeEnd​(long millisBeforeEnd)
        Creates a new animator configured to start after delayBeforeEnd milliseconds before the previous animation finishes with the last used target and interpolator.
      • createChildWithRawDelay

        protected T createChildWithRawDelay​(long delay)
      • createChildWithDelayAfterParentStart

        protected T createChildWithDelayAfterParentStart​(long delay,
                                                         boolean isStagger)
      • setParent

        protected T setParent​(T other)
        Copies all relevant attributes, including (ONLY) current target from `other` to self. Override if you have custom properties that need to be copied.
      • runIfParentIsInSameAnimationGroup

        protected void runIfParentIsInSameAnimationGroup​(Runnable r)