Search in sources :

Example 6 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter in project PhotoNoter by yydcdut.

the class EditTextActivity method finishActivityWithAnimation.

@Override
public void finishActivityWithAnimation(final boolean saved, final int categoryId, final int position, final int comparator) {
    int actionBarHeight = getActionBarSize();
    int screenHeight = Utils.sScreenHeight;
    int contentEditHeight = screenHeight - actionBarHeight;
    AnimatorSet animation = new AnimatorSet();
    animation.setDuration(Const.DURATION_ACTIVITY);
    animation.playTogether(ObjectAnimator.ofFloat(mAppBarLayout, "translationY", 0, -actionBarHeight), ObjectAnimator.ofFloat(mTitleTextInputLayout, "translationY", 0, -actionBarHeight * 3), ObjectAnimator.ofFloat(mContentEdit, "translationY", 0, contentEditHeight), ObjectAnimator.ofFloat(mFabMenuLayout, "translationY", 0, contentEditHeight), ObjectAnimator.ofFloat(mHorizontalEditScrollView, "translationY", 0, contentEditHeight));
    animation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!saved) {
                setResult(RESULT_NOTHING);
                EditTextActivity.this.finish();
                overridePendingTransition(R.anim.activity_no_animation, R.anim.activity_no_animation);
            } else {
                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putInt(Const.PHOTO_POSITION, position);
                bundle.putInt(Const.CATEGORY_ID_4_PHOTNOTES, categoryId);
                bundle.putInt(Const.COMPARATOR_FACTORY, comparator);
                intent.putExtras(bundle);
                setResult(RESULT_DATA, intent);
                EditTextActivity.this.finish();
                overridePendingTransition(R.anim.activity_no_animation, R.anim.activity_no_animation);
            }
        }
    });
    animation.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) Bundle(android.os.Bundle) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) Intent(android.content.Intent) Point(android.graphics.Point)

Example 7 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter in project PhotoNoter by yydcdut.

the class DetailActivity method initAnimationView.

@Override
public void initAnimationView() {
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(mCardView, "translationY", 0, mTranslateHeight));
            animatorSet.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mOverlayView.setVisibility(View.GONE);
                    mIsIgnoreClick = true;
                }

                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    mIsIgnoreClick = true;
                }
            });
            animatorSet.setDuration(400);
            animatorSet.setInterpolator(new DecelerateInterpolator());
            animatorSet.start();
            mAnimationHandler.postDelayed(mDownDelayRunnable, 350);
        }
    }, 500);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) Handler(android.os.Handler) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 8 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.

the class CheckableDrawable method setChecked.

public void setChecked(CheckedState state) {
    if (checkedState == state)
        return;
    if (checkedState == CheckedState.UNCHECKED) {
        if (state == CheckedState.CHECKED) {
            Animator fill = animateFill();
            fill.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    animateCheck().start();
                }
            });
            fill.start();
        } else {
            animateFill().start();
        }
    }
    if (checkedState == CheckedState.CHECKED) {
        if (state == CheckedState.UNCHECKED) {
            ValueAnimator check = animateCheck();
            check.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    animateFill().reverse();
                }
            });
            check.reverse();
        } else {
            animateCheck().reverse();
        }
    }
    if (checkedState == CheckedState.INDETERMINATE) {
        if (state == CheckedState.CHECKED) {
            animateCheck().start();
        } else {
            animateFill().reverse();
        }
    }
    checkedState = state;
    invalidateSelf();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 9 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.

the class CoordinatorLayout method setVisibility.

public void setVisibility(final int visibility) {
    if (visibility == View.VISIBLE && (getVisibility() != View.VISIBLE || animator != null)) {
        if (animator != null)
            animator.cancel();
        if (inAnim != AnimUtils.Style.None) {
            animator = AnimUtils.animateIn(this, inAnim, new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator a) {
                    animator = null;
                    clearAnimation();
                }
            });
        }
        super.setVisibility(visibility);
    } else if (visibility != View.VISIBLE && (getVisibility() == View.VISIBLE || animator != null)) {
        if (animator != null)
            animator.cancel();
        if (outAnim == AnimUtils.Style.None) {
            super.setVisibility(visibility);
            return;
        }
        animator = AnimUtils.animateOut(this, outAnim, new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator a) {
                if (((ValueAnimator) a).getAnimatedFraction() == 1)
                    CoordinatorLayout.super.setVisibility(visibility);
                animator = null;
                clearAnimation();
            }
        });
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) StateAnimator(carbon.animation.StateAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 10 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.

the class DefaultItemAnimator method animateMoveImpl.

private void animateMoveImpl(final RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    final ValueAnimator animation = ValueAnimator.ofFloat(0, 1);
    mMoveAnimations.add(holder);
    animation.setDuration(getMoveDuration());
    final float startX = ViewHelper.getTranslationX(view);
    final float startY = ViewHelper.getTranslationY(view);
    animation.addUpdateListener(__ -> {
        ViewHelper.setTranslationX(view, MathUtils.lerp(startX, 0, (Float) animation.getAnimatedValue()));
        ViewHelper.setTranslationY(view, MathUtils.lerp(startY, 0, (Float) animation.getAnimatedValue()));
    });
    animation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            dispatchMoveStarting(holder);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            if (deltaX != 0) {
                ViewHelper.setTranslationX(view, 0);
            }
            if (deltaY != 0) {
                ViewHelper.setTranslationY(view, 0);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            dispatchMoveFinished(holder);
            mMoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    });
    animation.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

Animator (com.nineoldandroids.animation.Animator)68 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)68 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)49 StateAnimator (carbon.animation.StateAnimator)29 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)16 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)11 View (android.view.View)10 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)7 RecyclerView (android.support.v7.widget.RecyclerView)5 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 MotionEvent (android.view.MotionEvent)3 ViewGroup (android.view.ViewGroup)3 ViewPropertyAnimator (android.view.ViewPropertyAnimator)3 AbsListView (android.widget.AbsListView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 IDetailView (com.yydcdut.note.views.note.IDetailView)2 FontTextView (com.yydcdut.note.widget.FontTextView)2