Search in sources :

Example 1 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project android_frameworks_base by ResurrectionRemix.

the class GlowBackground method getAnimator.

private Animator getAnimator(boolean hide) {
    float start = mCircleSize;
    float end = MAX_CIRCLE_SIZE;
    if (hide) {
        end = 0f;
    }
    ValueAnimator animator = ObjectAnimator.ofFloat(start, end);
    animator.setInterpolator(new AnticipateOvershootInterpolator());
    animator.setDuration(300);
    animator.addUpdateListener(this);
    return animator;
}
Also used : ValueAnimator(android.animation.ValueAnimator) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator)

Example 2 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project android_frameworks_base by ResurrectionRemix.

the class DessertCaseView method place.

public synchronized void place(View v, Point pt, boolean animate) {
    final int i = pt.x;
    final int j = pt.y;
    final float rnd = frand();
    if (v.getTag(TAG_POS) != null) {
        for (final Point oc : getOccupied(v)) {
            mFreeList.add(oc);
            mCells[oc.y * mColumns + oc.x] = null;
        }
    }
    int scale = 1;
    if (rnd < PROB_4X) {
        if (!(i >= mColumns - 3 || j >= mRows - 3)) {
            scale = 4;
        }
    } else if (rnd < PROB_3X) {
        if (!(i >= mColumns - 2 || j >= mRows - 2)) {
            scale = 3;
        }
    } else if (rnd < PROB_2X) {
        if (!(i == mColumns - 1 || j == mRows - 1)) {
            scale = 2;
        }
    }
    v.setTag(TAG_POS, pt);
    v.setTag(TAG_SPAN, scale);
    tmpSet.clear();
    final Point[] occupied = getOccupied(v);
    for (final Point oc : occupied) {
        final View squatter = mCells[oc.y * mColumns + oc.x];
        if (squatter != null) {
            tmpSet.add(squatter);
        }
    }
    for (final View squatter : tmpSet) {
        for (final Point sq : getOccupied(squatter)) {
            mFreeList.add(sq);
            mCells[sq.y * mColumns + sq.x] = null;
        }
        if (squatter != v) {
            squatter.setTag(TAG_POS, null);
            if (animate) {
                squatter.animate().withLayer().scaleX(0.5f).scaleY(0.5f).alpha(0).setDuration(DURATION).setInterpolator(new AccelerateInterpolator()).setListener(new Animator.AnimatorListener() {

                    public void onAnimationStart(Animator animator) {
                    }

                    public void onAnimationEnd(Animator animator) {
                        removeView(squatter);
                    }

                    public void onAnimationCancel(Animator animator) {
                    }

                    public void onAnimationRepeat(Animator animator) {
                    }
                }).start();
            } else {
                removeView(squatter);
            }
        }
    }
    for (final Point oc : occupied) {
        mCells[oc.y * mColumns + oc.x] = v;
        mFreeList.remove(oc);
    }
    final float rot = (float) irand(0, 4) * 90f;
    if (animate) {
        v.bringToFront();
        AnimatorSet set1 = new AnimatorSet();
        set1.playTogether(ObjectAnimator.ofFloat(v, View.SCALE_X, (float) scale), ObjectAnimator.ofFloat(v, View.SCALE_Y, (float) scale));
        set1.setInterpolator(new AnticipateOvershootInterpolator());
        set1.setDuration(DURATION);
        AnimatorSet set2 = new AnimatorSet();
        set2.playTogether(ObjectAnimator.ofFloat(v, View.ROTATION, rot), ObjectAnimator.ofFloat(v, View.X, i * mCellSize + (scale - 1) * mCellSize / 2), ObjectAnimator.ofFloat(v, View.Y, j * mCellSize + (scale - 1) * mCellSize / 2));
        set2.setInterpolator(new DecelerateInterpolator());
        set2.setDuration(DURATION);
        set1.addListener(makeHardwareLayerListener(v));
        set1.start();
        set2.start();
    } else {
        v.setX(i * mCellSize + (scale - 1) * mCellSize / 2);
        v.setY(j * mCellSize + (scale - 1) * mCellSize / 2);
        v.setScaleX((float) scale);
        v.setScaleY((float) scale);
        v.setRotation(rot);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorSet(android.animation.AnimatorSet) Point(android.graphics.Point) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) ImageView(android.widget.ImageView) View(android.view.View) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 3 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project android_frameworks_base by DirtyUnicorns.

the class DessertCaseView method place.

public synchronized void place(View v, Point pt, boolean animate) {
    final int i = pt.x;
    final int j = pt.y;
    final float rnd = frand();
    if (v.getTag(TAG_POS) != null) {
        for (final Point oc : getOccupied(v)) {
            mFreeList.add(oc);
            mCells[oc.y * mColumns + oc.x] = null;
        }
    }
    int scale = 1;
    if (rnd < PROB_4X) {
        if (!(i >= mColumns - 3 || j >= mRows - 3)) {
            scale = 4;
        }
    } else if (rnd < PROB_3X) {
        if (!(i >= mColumns - 2 || j >= mRows - 2)) {
            scale = 3;
        }
    } else if (rnd < PROB_2X) {
        if (!(i == mColumns - 1 || j == mRows - 1)) {
            scale = 2;
        }
    }
    v.setTag(TAG_POS, pt);
    v.setTag(TAG_SPAN, scale);
    tmpSet.clear();
    final Point[] occupied = getOccupied(v);
    for (final Point oc : occupied) {
        final View squatter = mCells[oc.y * mColumns + oc.x];
        if (squatter != null) {
            tmpSet.add(squatter);
        }
    }
    for (final View squatter : tmpSet) {
        for (final Point sq : getOccupied(squatter)) {
            mFreeList.add(sq);
            mCells[sq.y * mColumns + sq.x] = null;
        }
        if (squatter != v) {
            squatter.setTag(TAG_POS, null);
            if (animate) {
                squatter.animate().withLayer().scaleX(0.5f).scaleY(0.5f).alpha(0).setDuration(DURATION).setInterpolator(new AccelerateInterpolator()).setListener(new Animator.AnimatorListener() {

                    public void onAnimationStart(Animator animator) {
                    }

                    public void onAnimationEnd(Animator animator) {
                        removeView(squatter);
                    }

                    public void onAnimationCancel(Animator animator) {
                    }

                    public void onAnimationRepeat(Animator animator) {
                    }
                }).start();
            } else {
                removeView(squatter);
            }
        }
    }
    for (final Point oc : occupied) {
        mCells[oc.y * mColumns + oc.x] = v;
        mFreeList.remove(oc);
    }
    final float rot = (float) irand(0, 4) * 90f;
    if (animate) {
        v.bringToFront();
        AnimatorSet set1 = new AnimatorSet();
        set1.playTogether(ObjectAnimator.ofFloat(v, View.SCALE_X, (float) scale), ObjectAnimator.ofFloat(v, View.SCALE_Y, (float) scale));
        set1.setInterpolator(new AnticipateOvershootInterpolator());
        set1.setDuration(DURATION);
        AnimatorSet set2 = new AnimatorSet();
        set2.playTogether(ObjectAnimator.ofFloat(v, View.ROTATION, rot), ObjectAnimator.ofFloat(v, View.X, i * mCellSize + (scale - 1) * mCellSize / 2), ObjectAnimator.ofFloat(v, View.Y, j * mCellSize + (scale - 1) * mCellSize / 2));
        set2.setInterpolator(new DecelerateInterpolator());
        set2.setDuration(DURATION);
        set1.addListener(makeHardwareLayerListener(v));
        set1.start();
        set2.start();
    } else {
        v.setX(i * mCellSize + (scale - 1) * mCellSize / 2);
        v.setY(j * mCellSize + (scale - 1) * mCellSize / 2);
        v.setScaleX((float) scale);
        v.setScaleY((float) scale);
        v.setRotation(rot);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorSet(android.animation.AnimatorSet) Point(android.graphics.Point) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) ImageView(android.widget.ImageView) View(android.view.View) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 4 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project android_frameworks_base by crdroidandroid.

the class GlowBackground method getAnimator.

private Animator getAnimator(boolean hide) {
    float start = mCircleSize;
    float end = MAX_CIRCLE_SIZE;
    if (hide) {
        end = 0f;
    }
    ValueAnimator animator = ObjectAnimator.ofFloat(start, end);
    animator.setInterpolator(new AnticipateOvershootInterpolator());
    animator.setDuration(300);
    animator.addUpdateListener(this);
    return animator;
}
Also used : ValueAnimator(android.animation.ValueAnimator) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator)

Example 5 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project weiui by kuaifan.

the class RxAnimationTool method popout.

public static ObjectAnimator popout(final View view, final long duration, final AnimatorListenerAdapter animatorListenerAdapter) {
    ObjectAnimator popout = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1f, 0f), PropertyValuesHolder.ofFloat("scaleX", 1f, 0f), PropertyValuesHolder.ofFloat("scaleY", 1f, 0f));
    popout.setDuration(duration);
    popout.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(View.GONE);
            if (animatorListenerAdapter != null) {
                animatorListenerAdapter.onAnimationEnd(animation);
            }
        }
    });
    popout.setInterpolator(new AnticipateOvershootInterpolator());
    return popout;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator)

Aggregations

AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)16 ObjectAnimator (android.animation.ObjectAnimator)10 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)10 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)10 View (android.view.View)8 Animator (android.animation.Animator)7 ImageView (android.widget.ImageView)7 AnimatorSet (android.animation.AnimatorSet)5 Paint (android.graphics.Paint)5 Point (android.graphics.Point)5 ValueAnimator (android.animation.ValueAnimator)4 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)4 AnticipateInterpolator (android.view.animation.AnticipateInterpolator)4 BounceInterpolator (android.view.animation.BounceInterpolator)4 LinearInterpolator (android.view.animation.LinearInterpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 Typeface (android.graphics.Typeface)1