Search in sources :

Example 6 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project FlexibleAdapter by davideas.

the class SlideItemAnimator method animateRemoveImpl.

protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
    final View view = holder.itemView;
    ViewCompat.animate(view).cancel();
    return ViewCompat.animate(view).translationX(Utils.getScreenDimensions(holder.itemView.getContext()).x).setInterpolator(new AnticipateOvershootInterpolator());
}
Also used : AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) View(android.view.View)

Example 7 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project Reachability by sakebook.

the class CustomAnimationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_animation);
    ImageView view = new ImageView(this);
    view.setBackgroundResource(R.drawable.custom_button_selector);
    view.setScaleType(ImageView.ScaleType.CENTER);
    mReachability = new Reachability(this);
    mReachability.canTouchableBackView(true);
    mReachability.setBackImageResource(R.drawable.tiles);
    // Should call before makeHoverView!
    mReachability.setHoverView(view, android.R.drawable.ic_partial_secure, android.R.drawable.ic_secure);
    mReachability.makeHoverView(Reachability.Position.CENTER);
    mReachability.setCustomSlideInAnimation(1000, new AnticipateOvershootInterpolator(), fromLeftAnimation());
    mReachability.setCustomSlideOutAnimation(1000, new AnticipateOvershootInterpolator(), toRightAnimation());
    findViewById(R.id.switch_hover).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mReachability.switchHover();
        }
    });
}
Also used : ImageView(android.widget.ImageView) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) ImageView(android.widget.ImageView) View(android.view.View) Reachability(com.sakebook.android.library.reachability.Reachability)

Example 8 with AnticipateOvershootInterpolator

use of android.view.animation.AnticipateOvershootInterpolator in project platform_frameworks_base by android.

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 9 with AnticipateOvershootInterpolator

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

the class PAWorldActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    Typeface bold = Typeface.create("sans-serif", Typeface.BOLD);
    Typeface light = Typeface.create("sans-serif-light", Typeface.NORMAL);
    mContent = new FrameLayout(this);
    mContent.setBackgroundColor(CLEAR_BGCOLOR);
    final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER;
    final ImageView logo = new ImageView(this);
    logo.setImageResource(com.android.internal.R.drawable.pa_world_logo);
    logo.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    logo.setVisibility(View.INVISIBLE);
    final View bg = new View(this);
    bg.setBackgroundColor(SOLID_BGCOLOR);
    bg.setAlpha(0f);
    final TextView letter = new TextView(this);
    letter.setTypeface(bold);
    letter.setTextSize(200);
    letter.setTextColor(TEXT_COLOR);
    letter.setGravity(Gravity.CENTER);
    letter.setText("PA");
    final int p = (int) (4 * metrics.density);
    final TextView tv = new TextView(this);
    if (light != null)
        tv.setTypeface(light);
    tv.setTextSize(20);
    tv.setPadding(p, p, p, p);
    tv.setTextColor(TEXT_COLOR);
    tv.setGravity(Gravity.CENTER);
    tv.setTransformationMethod(new AllCapsTransformationMethod(this));
    String paVersion = SystemProperties.get("ro.pa.version");
    paVersion = paVersion.replaceAll("([0-9\\.]+?)-.*", "$1");
    tv.setText("Paranoid Android " + paVersion);
    tv.setVisibility(View.INVISIBLE);
    mContent.addView(bg);
    mContent.addView(letter, lp);
    mContent.addView(logo, lp);
    final FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(lp);
    lp2.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    lp2.bottomMargin = p;
    mContent.addView(tv, lp2);
    mContent.setOnClickListener(new View.OnClickListener() {

        int clicks;

        @Override
        public void onClick(View v) {
            clicks++;
            if (clicks >= 6) {
                mContent.performLongClick();
                return;
            }
            letter.animate().cancel();
            final float offset = (int) letter.getRotation() % 360;
            letter.animate().rotationBy((Math.random() > 0.5f ? 360 : -360) - offset).setInterpolator(new DecelerateInterpolator()).setDuration(700).start();
        }
    });
    mContent.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if (logo.getVisibility() != View.VISIBLE) {
                bg.setScaleX(0.01f);
                bg.animate().alpha(1f).scaleX(1f).setStartDelay(500).start();
                letter.animate().alpha(0f).scaleY(0.5f).scaleX(0.5f).rotationBy(360).setInterpolator(new AccelerateInterpolator()).setDuration(1000).start();
                logo.setAlpha(0f);
                logo.setVisibility(View.VISIBLE);
                logo.setScaleX(0.5f);
                logo.setScaleY(0.5f);
                logo.animate().alpha(1f).scaleX(1f).scaleY(1f).setDuration(1000).setStartDelay(500).setInterpolator(new AnticipateOvershootInterpolator()).start();
                tv.setAlpha(0f);
                tv.setVisibility(View.VISIBLE);
                tv.animate().alpha(1f).setDuration(1000).setStartDelay(1000).start();
                return true;
            }
            return false;
        }
    });
    logo.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            try {
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.setClassName("com.android.settings", "com.android.settings.BeanBag").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getBaseContext().startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
            } catch (ActivityNotFoundException ex) {
                android.util.Log.e("PAWorldActivity", "Couldn't catch a break.");
            }
            finish();
            return true;
        }
    });
    setContentView(mContent);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) Typeface(android.graphics.Typeface) Intent(android.content.Intent) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) DisplayMetrics(android.util.DisplayMetrics) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AllCapsTransformationMethod(android.text.method.AllCapsTransformationMethod) ActivityNotFoundException(android.content.ActivityNotFoundException) FrameLayout(android.widget.FrameLayout) UserHandle(android.os.UserHandle) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 10 with AnticipateOvershootInterpolator

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

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)

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