Search in sources :

Example 1 with RxFakeAddImageView

use of com.vondear.tools.view.RxFakeAddImageView in project RxTools by vondear.

the class ActivityELMe method add.

@Override
public void add(View view, int position) {
    int[] addLocation = new int[2];
    int[] cartLocation = new int[2];
    int[] recycleLocation = new int[2];
    view.getLocationInWindow(addLocation);
    mShoppingCart.getLocationInWindow(cartLocation);
    mRightMenu.getLocationInWindow(recycleLocation);
    PointF startP = new PointF();
    PointF endP = new PointF();
    PointF controlP = new PointF();
    startP.x = addLocation[0];
    startP.y = addLocation[1] - recycleLocation[1];
    endP.x = cartLocation[0];
    endP.y = cartLocation[1] - recycleLocation[1];
    controlP.x = endP.x;
    controlP.y = startP.y;
    final RxFakeAddImageView rxFakeAddImageView = new RxFakeAddImageView(this);
    mMainLayout.addView(rxFakeAddImageView);
    rxFakeAddImageView.setImageResource(R.drawable.ic_add_circle_blue_700_36dp);
    rxFakeAddImageView.getLayoutParams().width = getResources().getDimensionPixelSize(R.dimen.item_dish_circle_size);
    rxFakeAddImageView.getLayoutParams().height = getResources().getDimensionPixelSize(R.dimen.item_dish_circle_size);
    rxFakeAddImageView.setVisibility(View.VISIBLE);
    ObjectAnimator addAnimator = ObjectAnimator.ofObject(rxFakeAddImageView, "mPointF", new RxPointFTypeEvaluator(controlP), startP, endP);
    addAnimator.setInterpolator(new AccelerateInterpolator());
    addAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            rxFakeAddImageView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            rxFakeAddImageView.setVisibility(View.GONE);
            mMainLayout.removeView(rxFakeAddImageView);
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    ObjectAnimator scaleAnimatorX = new ObjectAnimator().ofFloat(mShoppingCart, "scaleX", 0.6f, 1.0f);
    ObjectAnimator scaleAnimatorY = new ObjectAnimator().ofFloat(mShoppingCart, "scaleY", 0.6f, 1.0f);
    scaleAnimatorX.setInterpolator(new AccelerateInterpolator());
    scaleAnimatorY.setInterpolator(new AccelerateInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(scaleAnimatorX).with(scaleAnimatorY).after(addAnimator);
    animatorSet.setDuration(800);
    animatorSet.start();
    showTotalPrice();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) PointF(android.graphics.PointF) AnimatorSet(android.animation.AnimatorSet) RxFakeAddImageView(com.vondear.tools.view.RxFakeAddImageView) RxPointFTypeEvaluator(com.vondear.tools.view.RxPointFTypeEvaluator)

Aggregations

Animator (android.animation.Animator)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 PointF (android.graphics.PointF)1 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)1 RxFakeAddImageView (com.vondear.tools.view.RxFakeAddImageView)1 RxPointFTypeEvaluator (com.vondear.tools.view.RxPointFTypeEvaluator)1