Search in sources :

Example 26 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter 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 27 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter in project material-sheet-fab by gowong.

the class FabAnimation method startArcAnim.

protected void startArcAnim(View view, float endX, float endY, float degrees, Side side, long duration, Interpolator interpolator, final AnimationListener listener) {
    // Setup animation
    // Cast end coordinates to ints so that the FAB will be animated to the same position even
    // when there are minute differences in the coordinates
    ArcAnimator anim = ArcAnimator.createArcAnimator(view, (int) endX, (int) endY, degrees, side);
    anim.setDuration(duration);
    anim.setInterpolator(interpolator);
    // Add listener
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            if (listener != null) {
                listener.onStart();
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (listener != null) {
                listener.onEnd();
            }
        }
    });
    // Start animation
    anim.start();
}
Also used : ArcAnimator(io.codetail.animation.arcanimator.ArcAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ArcAnimator(io.codetail.animation.arcanimator.ArcAnimator)

Example 28 with AnimatorListenerAdapter

use of com.nineoldandroids.animation.AnimatorListenerAdapter 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 29 with AnimatorListenerAdapter

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

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