Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87f4ae67 authored by Chet Haase's avatar Chet Haase
Browse files

Add updateListener to ViewPropertyAnimator

New method setUpdateListener() on ViewPropertyAnimator that will
send out update events to the provided listener.

Issue #10118113 Offer update listener on ViewPropertyAnimator

Change-Id: Ib9f8fc6dbbc3c1c58113246d9a3b01e7ac27b14c
parent bbddd49d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28372,6 +28372,7 @@ package android.view {
    method public android.view.ViewPropertyAnimator setInterpolator(android.animation.TimeInterpolator);
    method public android.view.ViewPropertyAnimator setListener(android.animation.Animator.AnimatorListener);
    method public android.view.ViewPropertyAnimator setStartDelay(long);
    method public android.view.ViewPropertyAnimator setUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener);
    method public void start();
    method public android.view.ViewPropertyAnimator translationX(float);
    method public android.view.ViewPropertyAnimator translationXBy(float);
+32 −2
Original line number Diff line number Diff line
@@ -93,10 +93,15 @@ public class ViewPropertyAnimator {
    private boolean mInterpolatorSet = false;

    /**
     * Listener for the lifecycle events of the underlying 
     * Listener for the lifecycle events of the underlying ValueAnimator object.
     */
    private Animator.AnimatorListener mListener = null;

    /**
     * Listener for the update events of the underlying ValueAnimator object.
     */
    private ValueAnimator.AnimatorUpdateListener mUpdateListener = null;

    /**
     * A lazily-created ValueAnimator used in order to get some default animator properties
     * (duration, start delay, interpolator, etc.).
@@ -353,7 +358,10 @@ public class ViewPropertyAnimator {
     * Sets a listener for events in the underlying Animators that run the property
     * animations.
     *
     * @param listener The listener to be called with AnimatorListener events.
     * @see Animator.AnimatorListener
     *
     * @param listener The listener to be called with AnimatorListener events. A value of
     * <code>null</code> removes any existing listener.
     * @return This object, allowing calls to methods in this class to be chained.
     */
    public ViewPropertyAnimator setListener(Animator.AnimatorListener listener) {
@@ -361,6 +369,25 @@ public class ViewPropertyAnimator {
        return this;
    }

    /**
     * Sets a listener for update events in the underlying ValueAnimator that runs
     * the property animations. Note that the underlying animator is animating between
     * 0 and 1 (these values are then turned into the actual property values internally
     * by ViewPropertyAnimator). So the animator cannot give information on the current
     * values of the properties being animated by this ViewPropertyAnimator, although
     * the view object itself can be queried to get the current values.
     *
     * @see android.animation.ValueAnimator.AnimatorUpdateListener
     *
     * @param listener The listener to be called with update events. A value of
     * <code>null</code> removes any existing listener.
     * @return This object, allowing calls to methods in this class to be chained.
     */
    public ViewPropertyAnimator setUpdateListener(ValueAnimator.AnimatorUpdateListener listener) {
        mUpdateListener = listener;
        return this;
    }

    /**
     * Starts the currently pending property animations immediately. Calling <code>start()</code>
     * is optional because all animations start automatically at the next opportunity. However,
@@ -1073,6 +1100,9 @@ public class ViewPropertyAnimator {
            } else {
                mView.invalidateViewProperty(false, false);
            }
            if (mUpdateListener != null) {
                mUpdateListener.onAnimationUpdate(animation);
            }
        }
    }
}