Search in sources :

Example 46 with AnimatorListenerAdapter

use of android.animation.AnimatorListenerAdapter in project JJSearchViewAnim by android-cjj.

the class JJBaseController method startSearchViewAnim.

public ValueAnimator startSearchViewAnim(float startF, float endF, long time, final PathMeasure pathMeasure) {
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(startF, endF);
    valueAnimator.setDuration(time);
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mPro = (float) valueAnimator.getAnimatedValue();
            if (null != pathMeasure)
                pathMeasure.getPosTan(mPro, mPos, null);
            getSearchView().invalidate();
        }
    });
    valueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    mPro = 0;
    return valueAnimator;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 47 with AnimatorListenerAdapter

use of android.animation.AnimatorListenerAdapter in project android-demos by novoda.

the class VisibilityController method setVisible.

boolean setVisible(final boolean visible, boolean animated) {
    if (isVisible() == visible) {
        return false;
    }
    mVisible = visible;
    if (animated) {
        float toAlpha = visible ? 1.0f : 0.0f;
        ObjectAnimator mAnimator = ObjectAnimator.ofFloat(mView, "Alpha", 1 - toAlpha, toAlpha);
        mAnimator.setDuration(mAnimationDuration).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animator) {
                if (visible) {
                    setViewVisible(true);
                }
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                if (!visible) {
                    setViewVisible(false);
                }
            }
        });
        mAnimator.start();
    } else {
        setViewVisible(visible);
    }
    return true;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 48 with AnimatorListenerAdapter

use of android.animation.AnimatorListenerAdapter in project weiciyuan by qii.

the class GalleryActivity method animateClose.

private void animateClose(PhotoView imageView) {
    currentViewPositionLayout.setVisibility(View.INVISIBLE);
    animationView.setImageDrawable(imageView.getDrawable());
    pager.setVisibility(View.INVISIBLE);
    final Rect startBounds = rect;
    final Rect finalBounds = new Rect();
    final Point globalOffset = new Point();
    animationView.getGlobalVisibleRect(finalBounds, globalOffset);
    startBounds.offset(-globalOffset.x, -globalOffset.y);
    finalBounds.offset(-globalOffset.x, -globalOffset.y);
    float startScale;
    if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) {
        // Extend start bounds horizontally
        startScale = (float) startBounds.height() / finalBounds.height();
        float startWidth = startScale * finalBounds.width();
        float deltaWidth = (startWidth - startBounds.width()) / 2;
        startBounds.left -= deltaWidth;
        startBounds.right += deltaWidth;
    } else {
        // Extend start bounds vertically
        startScale = (float) startBounds.width() / finalBounds.width();
        float startHeight = startScale * finalBounds.height();
        float deltaHeight = (startHeight - startBounds.height()) / 2;
        startBounds.top -= deltaHeight;
        startBounds.bottom += deltaHeight;
    }
    animationView.setPivotX(0f);
    animationView.setPivotY(0f);
    final float startScaleFinal = startScale;
    animationView.animate().setInterpolator(new DecelerateInterpolator()).x(startBounds.left).y(startBounds.top).scaleY(startScaleFinal).scaleX(startScaleFinal).setDuration(300).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            GalleryActivity.this.finish();
            overridePendingTransition(0, 0);
        }
    }).start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Rect(android.graphics.Rect) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Point(android.graphics.Point)

Example 49 with AnimatorListenerAdapter

use of android.animation.AnimatorListenerAdapter in project weiciyuan by qii.

the class GalleryAnimationActivity method onBackPressed.

@Override
public void onBackPressed() {
    ContainerFragment fragment = fragmentMap.get(pager.getCurrentItem());
    if (fragment != null && fragment.canAnimateCloseActivity()) {
        backgroundColor = new ColorDrawable(Color.BLACK);
        ObjectAnimator bgAnim = ObjectAnimator.ofInt(backgroundColor, "alpha", 0);
        bgAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                background.setBackground(backgroundColor);
            }
        });
        bgAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                GalleryAnimationActivity.super.finish();
                overridePendingTransition(-1, -1);
            }
        });
        fragment.animationExit(bgAnim);
    } else {
        super.onBackPressed();
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ColorDrawable(android.graphics.drawable.ColorDrawable) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 50 with AnimatorListenerAdapter

use of android.animation.AnimatorListenerAdapter in project platform_frameworks_base by android.

the class LockPatternView method startLineEndAnimation.

private void startLineEndAnimation(final CellState state, final float startX, final float startY, final float targetX, final float targetY) {
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float t = (float) animation.getAnimatedValue();
            state.lineEndX = (1 - t) * startX + t * targetX;
            state.lineEndY = (1 - t) * startY + t * targetY;
            invalidate();
        }
    });
    valueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            state.lineAnimator = null;
        }
    });
    valueAnimator.setInterpolator(mFastOutSlowInInterpolator);
    valueAnimator.setDuration(100);
    valueAnimator.start();
    state.lineAnimator = valueAnimator;
}
Also used : Animator(android.animation.Animator) RenderNodeAnimator(android.view.RenderNodeAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Aggregations

Animator (android.animation.Animator)868 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)868 ObjectAnimator (android.animation.ObjectAnimator)464 ValueAnimator (android.animation.ValueAnimator)459 AnimatorSet (android.animation.AnimatorSet)144 View (android.view.View)131 ViewGroup (android.view.ViewGroup)92 PropertyValuesHolder (android.animation.PropertyValuesHolder)70 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)70 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)62 ImageView (android.widget.ImageView)45 TextView (android.widget.TextView)43 Interpolator (android.view.animation.Interpolator)42 Paint (android.graphics.Paint)41 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)41 Rect (android.graphics.Rect)40 RenderNodeAnimator (android.view.RenderNodeAnimator)36 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)36 TimeAnimator (android.animation.TimeAnimator)30 TargetApi (android.annotation.TargetApi)30