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

Commit ef52176f authored by Adam Cohen's avatar Adam Cohen
Browse files

Changing AdapterViewAnimator to use the new animation APIs

Change-Id: Ifefb83c391914ac623d75e0faca723b95786861d
parent 066b5c51
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -223783,7 +223783,7 @@
>
</method>
<method name="getInAnimation"
 return="android.view.animation.Animation"
 return="android.animation.ObjectAnimator&lt;?&gt;"
 abstract="false"
 native="false"
 synchronized="false"
@@ -223794,7 +223794,7 @@
>
</method>
<method name="getOutAnimation"
 return="android.view.animation.Animation"
 return="android.animation.ObjectAnimator&lt;?&gt;"
 abstract="false"
 native="false"
 synchronized="false"
@@ -223910,7 +223910,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="inAnimation" type="android.view.animation.Animation">
<parameter name="inAnimation" type="android.animation.ObjectAnimator&lt;?&gt;">
</parameter>
</method>
<method name="setInAnimation"
@@ -223938,7 +223938,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="outAnimation" type="android.view.animation.Animation">
<parameter name="outAnimation" type="android.animation.ObjectAnimator&lt;?&gt;">
</parameter>
</method>
<method name="setOutAnimation"
+29 −29
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.widget;
import java.util.ArrayList;
import java.util.HashMap;

import android.animation.AnimatorInflater;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.Intent;
@@ -135,12 +136,15 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
    int mReferenceChildHeight = -1;

    /**
     * TODO: Animation stuff is still in flux, waiting on the new framework to settle a bit.
     * In and out animations.
     */
    Animation mInAnimation;
    Animation mOutAnimation;
    ObjectAnimator<?> mInAnimation;
    ObjectAnimator<?> mOutAnimation;

    private  ArrayList<View> mViewsToBringToFront;

    private static final int DEFAULT_ANIMATION_DURATION = 200;

    public AdapterViewAnimator(Context context) {
        super(context);
        initViewAnimator();
@@ -155,11 +159,15 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
                com.android.internal.R.styleable.AdapterViewAnimator_inAnimation, 0);
        if (resource > 0) {
            setInAnimation(context, resource);
        } else {
            setInAnimation(getDefaultInAnimation());
        }

        resource = a.getResourceId(com.android.internal.R.styleable.AdapterViewAnimator_outAnimation, 0);
        if (resource > 0) {
            setOutAnimation(context, resource);
        } else {
            setOutAnimation(getDefaultOutAnimation());
        }

        boolean flag = a.getBoolean(
@@ -229,17 +237,23 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @param view The view that is being animated
     */
    void animateViewForTransition(int fromIndex, int toIndex, View view) {
        ObjectAnimator pa;
        if (fromIndex == -1) {
            view.setAlpha(0.0f);
            pa = new ObjectAnimator(400, view, "alpha", 0.0f, 1.0f);
            pa.start();
            mInAnimation.setTarget(view);
            mInAnimation.start();
        } else if (toIndex == -1) {
            pa = new ObjectAnimator(400, view, "alpha", 1.0f, 0.0f);
            pa.start();
            mOutAnimation.setTarget(view);
            mOutAnimation.start();
        }
    }

    ObjectAnimator<?> getDefaultInAnimation() {
        return new ObjectAnimator<Float>(DEFAULT_ANIMATION_DURATION, null, "alpha", 0.0f, 1.0f);
    }

    ObjectAnimator<?> getDefaultOutAnimation() {
        return new ObjectAnimator<Float>(DEFAULT_ANIMATION_DURATION, null, "alpha", 1.0f, 0.0f);
    }

    /**
     * Sets which child view will be displayed.
     *
@@ -264,20 +278,6 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
        }
    }

    /**
     * Return default inAnimation. To be overriden by subclasses.
     */
    Animation getDefaultInAnimation() {
        return null;
    }

    /**
     * Return default outAnimation. To be overridden by subclasses.
     */
    Animation getDefaultOutAnimation() {
        return null;
    }

    /**
     * To be overridden by subclasses. This method applies a view / index specific
     * transform to the child view.
@@ -690,7 +690,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @see #setInAnimation(android.view.animation.Animation)
     * @see #setInAnimation(android.content.Context, int)
     */
    public Animation getInAnimation() {
    public ObjectAnimator<?> getInAnimation() {
        return mInAnimation;
    }

@@ -702,7 +702,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @see #getInAnimation()
     * @see #setInAnimation(android.content.Context, int)
     */
    public void setInAnimation(Animation inAnimation) {
    public void setInAnimation(ObjectAnimator<?> inAnimation) {
        mInAnimation = inAnimation;
    }

@@ -714,7 +714,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @see #setOutAnimation(android.view.animation.Animation)
     * @see #setOutAnimation(android.content.Context, int)
     */
    public Animation getOutAnimation() {
    public ObjectAnimator<?> getOutAnimation() {
        return mOutAnimation;
    }

@@ -726,7 +726,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @see #getOutAnimation()
     * @see #setOutAnimation(android.content.Context, int)
     */
    public void setOutAnimation(Animation outAnimation) {
    public void setOutAnimation(ObjectAnimator<?> outAnimation) {
        mOutAnimation = outAnimation;
    }

@@ -740,7 +740,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @see #setInAnimation(android.view.animation.Animation)
     */
    public void setInAnimation(Context context, int resourceID) {
        setInAnimation(AnimationUtils.loadAnimation(context, resourceID));
        setInAnimation((ObjectAnimator<?>) AnimatorInflater.loadAnimator(context, resourceID));
    }

    /**
@@ -753,7 +753,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * @see #setOutAnimation(android.view.animation.Animation)
     */
    public void setOutAnimation(Context context, int resourceID) {
        setOutAnimation(AnimationUtils.loadAnimation(context, resourceID));
        setOutAnimation((ObjectAnimator<?>) AnimatorInflater.loadAnimator(context, resourceID));
    }

    /**
+1 −16
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.widget;

import android.animation.ObjectAnimator;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -43,10 +44,8 @@ public class AdapterViewFlipper extends AdapterViewAnimator {
    private static final boolean LOGD = false;

    private static final int DEFAULT_INTERVAL = 10000;
    private static final int DEFAULT_ANIMATION_DURATION = 200;

    private int mFlipInterval = DEFAULT_INTERVAL;
    private int mAnimationDuration = DEFAULT_ANIMATION_DURATION;
    private boolean mAutoStart = false;

    private boolean mRunning = false;
@@ -56,7 +55,6 @@ public class AdapterViewFlipper extends AdapterViewAnimator {

    public AdapterViewFlipper(Context context) {
        super(context);
        initDefaultAnimations();
    }

    public AdapterViewFlipper(Context context, AttributeSet attrs) {
@@ -74,19 +72,6 @@ public class AdapterViewFlipper extends AdapterViewAnimator {
                com.android.internal.R.styleable.AdapterViewAnimator_loopViews, true);

        a.recycle();
        initDefaultAnimations();
    }

    private void initDefaultAnimations() {
        // Set the default animations to be fade in/out
        if (mInAnimation == null) {
            mInAnimation = new AlphaAnimation(0.0f, 1.0f);
            mInAnimation.setDuration(mAnimationDuration);
        }
        if (mOutAnimation == null) {
            mOutAnimation = new AlphaAnimation(1.0f, 0.0f);
            mOutAnimation.setDuration(mAnimationDuration);
        }
    }

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {