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

Commit b89473db authored by Jelle Fresen's avatar Jelle Fresen
Browse files

Revert addition of add/removeAnimationListener

This reverts commit 02301df2
and 65d2171d.

Dropped addition of new API because androidx's FragmentManagerImpl now
employs a workaround that removes the necessity to reflect into
mListener and doesn't need add/removeAnimationListener either.

Bug: 117519981
Test: atest AnimationTest
Change-Id: I7250570190f40f6c5da8ef65ed81b2d4bb815cf5
parent fcc43575
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -52609,7 +52609,6 @@ package android.view.animation {
  public abstract class Animation implements java.lang.Cloneable {
    ctor public Animation();
    ctor public Animation(android.content.Context, android.util.AttributeSet);
    method public void addAnimationListener(android.view.animation.Animation.AnimationListener);
    method protected void applyTransformation(float, android.view.animation.Transformation);
    method public void cancel();
    method protected android.view.animation.Animation clone() throws java.lang.CloneNotSupportedException;
@@ -52634,7 +52633,6 @@ package android.view.animation {
    method public void initialize(int, int, int, int);
    method public boolean isFillEnabled();
    method public boolean isInitialized();
    method public void removeAnimationListener(android.view.animation.Animation.AnimationListener);
    method public void reset();
    method protected float resolveSize(int, float, int, int);
    method public void restrictDuration(long);
+5 −51
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.RectF;
import android.os.Build;
import android.os.Handler;
import android.os.SystemProperties;
import android.util.AttributeSet;
@@ -30,9 +31,6 @@ import android.util.TypedValue;

import dalvik.system.CloseGuard;

import java.util.ArrayList;
import java.util.List;

/**
 * Abstraction for an Animation that can be applied to Views, Surfaces, or
 * other objects. See the {@link android.view.animation animation package
@@ -187,14 +185,11 @@ public abstract class Animation implements Cloneable {
    /**
     * An animation listener to be notified when the animation starts, ends or repeats.
     */
    @UnsupportedAppUsage
    // If you need to chain the AnimationListener, wrap the existing Animation into an AnimationSet
    // and add your new listener to that set
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 117519981)
    private AnimationListener mListener;

    /**
     * A list of animation listeners to be notified when the animation starts, ends or repeats.
     */
    private List<AnimationListener> mListeners;

    /**
     * Desired Z order mode during animation.
     */
@@ -833,7 +828,7 @@ public abstract class Animation implements Cloneable {
    }

    private boolean hasAnimationListener() {
        return mListener != null || (mListeners != null && !mListeners.isEmpty());
        return mListener != null;
    }

    /**
@@ -847,32 +842,6 @@ public abstract class Animation implements Cloneable {
        mListener = listener;
    }

    /**
     * <p>Adds an animation listener to this animation. The animation listener
     * is notified of animation events such as the end of the animation or the
     * repetition of the animation.</p>
     *
     * @param listener the animation listener to be notified
     */
    public void addAnimationListener(AnimationListener listener) {
        if (mListeners == null) {
            mListeners = new ArrayList<>(1);
        }
        mListeners.add(listener);
    }

    /**
     * <p>Removes an animation listener that has been added with
     * {@link #addAnimationListener(AnimationListener)}.</p>
     *
     * @param listener the animation listener to be removed
     */
    public void removeAnimationListener(AnimationListener listener) {
        if (mListeners != null) {
            mListeners.remove(listener);
        }
    }

    /**
     * Gurantees that this animation has an interpolator. Will use
     * a AccelerateDecelerateInterpolator is nothing else was specified.
@@ -1003,33 +972,18 @@ public abstract class Animation implements Cloneable {
        if (mListener != null) {
            mListener.onAnimationStart(this);
        }
        if (mListeners != null && !mListeners.isEmpty()) {
            for (AnimationListener listener : mListeners) {
                listener.onAnimationStart(this);
            }
        }
    }

    void dispatchAnimationRepeat() {
        if (mListener != null) {
            mListener.onAnimationRepeat(this);
        }
        if (mListeners != null && !mListeners.isEmpty()) {
            for (AnimationListener listener : mListeners) {
                listener.onAnimationRepeat(this);
            }
        }
    }

    void dispatchAnimationEnd() {
        if (mListener != null) {
            mListener.onAnimationEnd(this);
        }
        if (mListeners != null && !mListeners.isEmpty()) {
            for (AnimationListener listener : mListeners) {
                listener.onAnimationEnd(this);
            }
        }
    }

    /**