Search in sources :

Example 36 with Animator

use of com.nineoldandroids.animation.Animator in project fresco by facebook.

the class AnimatedZoomableControllerSupport method setTransformAnimated.

public void setTransformAnimated(final Matrix newTransform, long durationMs, @Nullable final Runnable onAnimationComplete) {
    FLog.v(getLogTag(), "setTransformAnimated: duration %d ms", durationMs);
    stopAnimation();
    Preconditions.checkArgument(durationMs > 0);
    Preconditions.checkState(!isAnimating());
    setAnimating(true);
    mValueAnimator.setDuration(durationMs);
    getTransform().getValues(getStartValues());
    newTransform.getValues(getStopValues());
    mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            calculateInterpolation(getWorkingTransform(), (float) valueAnimator.getAnimatedValue());
            AnimatedZoomableControllerSupport.super.setTransform(getWorkingTransform());
        }
    });
    mValueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationCancel(Animator animation) {
            FLog.v(getLogTag(), "setTransformAnimated: animation cancelled");
            onAnimationStopped();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            FLog.v(getLogTag(), "setTransformAnimated: animation finished");
            onAnimationStopped();
        }

        private void onAnimationStopped() {
            if (onAnimationComplete != null) {
                onAnimationComplete.run();
            }
            setAnimating(false);
            getDetector().restartGesture();
        }
    });
    mValueAnimator.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 37 with Animator

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

the class SettingActivity method closeActivityAnimation.

private void closeActivityAnimation() {
    int actionBarHeight = getActionBarSize();
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int screenHeight = dm.heightPixels;
    int contentHeight = screenHeight - actionBarHeight;
    AnimatorSet animation = new AnimatorSet();
    animation.setDuration(Const.DURATION_ACTIVITY);
    animation.playTogether(ObjectAnimator.ofFloat(mToolbarLayout, "translationY", 0, -actionBarHeight), ObjectAnimator.ofFloat(mScrollView, "translationY", 0, contentHeight));
    animation.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mIsHiding = false;
            finish();
            overridePendingTransition(R.anim.activity_no_animation, R.anim.activity_no_animation);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animation.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) DisplayMetrics(android.util.DisplayMetrics)

Example 38 with Animator

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

the class AnimationTopLayout method doAnimation.

public void doAnimation() {
    ObjectAnimator downAnimation = ObjectAnimator.ofFloat(mChildView, "Y", 0f, getResources().getDimension(R.dimen.dimen_48dip));
    downAnimation.setDuration(ANIMATION_TIME / 2);
    downAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (mOnAnimationHalfFinishListener != null) {
                mOnAnimationHalfFinishListener.onHalf(mChildView);
            }
        }
    });
    ObjectAnimator upAnimation = ObjectAnimator.ofFloat(mChildView, "Y", -getResources().getDimension(R.dimen.dimen_48dip), 0f);
    upAnimation.setDuration(ANIMATION_TIME / 2);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(downAnimation, upAnimation);
    animatorSet.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 39 with Animator

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

the class FeedbackActivity method startSendingAnimation.

private void startSendingAnimation(final RevealView.RevealAnimationListener listener) {
    final int width = mFab.getLeft();
    final int height = mFab.getTop();
    ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setDuration(Const.DURATION / 2);
    valueAnimator.setObjectValues(new PointF(0, 0));
    valueAnimator.setInterpolator(new DecelerateInterpolator());
    valueAnimator.setEvaluator(new TypeEvaluator<PointF>() {

        @Override
        public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
            PointF point = new PointF();
            point.x = (width) * (1 - fraction / 2);
            point.y = (height) - 0.85f * (height) * (fraction / 2) * (fraction / 2);
            return point;
        }
    });
    valueAnimator.start();
    valueAnimator.addUpdateListener((animation) -> {
        PointF point = (PointF) animation.getAnimatedValue();
        mFab.setX(point.x);
        mFab.setY(point.y);
    });
    valueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mRevealView.reveal((int) mFab.getX() + mFab.getWidth() / 2, (int) mFab.getY() + mFab.getHeight() / 2, getThemeColor(), Const.RADIUS, Const.DURATION, listener);
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) PointF(android.graphics.PointF) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 40 with Animator

use of com.nineoldandroids.animation.Animator 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)

Aggregations

Animator (com.nineoldandroids.animation.Animator)139 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)83 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)67 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)53 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)29 StateAnimator (carbon.animation.StateAnimator)28 View (android.view.View)27 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)13 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 RecyclerView (android.support.v7.widget.RecyclerView)6 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 ViewGroup (android.view.ViewGroup)5 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 ArcAnimator (io.codetail.animation.arcanimator.ArcAnimator)4 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)3 GestureDetector (android.view.GestureDetector)3