Search in sources :

Example 96 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class NotificationSettingsIconRow method fadeInSettings.

public void fadeInSettings(final boolean fromLeft, final float transX, final float notiThreshold) {
    if (mDismissing || mAnimating) {
        return;
    }
    if (isIconLocationChange(transX)) {
        setGearAlpha(0f);
    }
    setIconLocation(transX > 0);
    mFadeAnimator = ValueAnimator.ofFloat(mGearIcon.getAlpha(), 1);
    mFadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final float absTrans = Math.abs(transX);
            boolean pastGear = (fromLeft && transX <= notiThreshold) || (!fromLeft && absTrans <= notiThreshold);
            if (pastGear && !mSettingsFadedIn) {
                setGearAlpha((float) animation.getAnimatedValue());
            }
        }
    });
    mFadeAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            mAnimating = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            // TODO should animate back to 0f from current alpha
            mGearIcon.setAlpha(0f);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimating = false;
            mSettingsFadedIn = mGearIcon.getAlpha() == 1;
        }
    });
    mFadeAnimator.setInterpolator(Interpolators.ALPHA_IN);
    mFadeAnimator.setDuration(GEAR_ALPHA_ANIM_DURATION);
    mFadeAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 97 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class KeyguardAffordanceView method getAnimatorToRadius.

private ValueAnimator getAnimatorToRadius(float circleRadius) {
    ValueAnimator animator = ValueAnimator.ofFloat(mCircleRadius, circleRadius);
    mCircleAnimator = animator;
    mCircleStartValue = mCircleRadius;
    mCircleWillBeHidden = circleRadius == 0.0f;
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mCircleRadius = (float) animation.getAnimatedValue();
            updateIconColor();
            invalidate();
        }
    });
    animator.addListener(mCircleEndListener);
    return animator;
}
Also used : ValueAnimator(android.animation.ValueAnimator)

Example 98 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class NightDisplayService method onActivated.

@Override
public void onActivated(boolean activated) {
    if (mIsActivated == null || mIsActivated != activated) {
        Slog.i(TAG, activated ? "Turning on night display" : "Turning off night display");
        if (mAutoMode != null) {
            mAutoMode.onActivated(activated);
        }
        mIsActivated = activated;
        // Cancel the old animator if still running.
        if (mColorMatrixAnimator != null) {
            mColorMatrixAnimator.cancel();
        }
        // Don't do any color matrix change animations if we are ignoring them anyway.
        if (mIgnoreAllColorMatrixChanges.get()) {
            return;
        }
        final DisplayTransformManager dtm = getLocalService(DisplayTransformManager.class);
        final float[] from = dtm.getColorMatrix(LEVEL_COLOR_MATRIX_NIGHT_DISPLAY);
        final float[] to = mIsActivated ? MATRIX_NIGHT : null;
        mColorMatrixAnimator = ValueAnimator.ofObject(COLOR_MATRIX_EVALUATOR, from == null ? MATRIX_IDENTITY : from, to == null ? MATRIX_IDENTITY : to);
        mColorMatrixAnimator.setDuration(getContext().getResources().getInteger(android.R.integer.config_longAnimTime));
        mColorMatrixAnimator.setInterpolator(AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in));
        mColorMatrixAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                final float[] value = (float[]) animator.getAnimatedValue();
                dtm.setColorMatrix(LEVEL_COLOR_MATRIX_NIGHT_DISPLAY, value);
            }
        });
        mColorMatrixAnimator.addListener(new AnimatorListenerAdapter() {

            private boolean mIsCancelled;

            @Override
            public void onAnimationCancel(Animator animator) {
                mIsCancelled = true;
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                if (!mIsCancelled) {
                    // Ensure final color matrix is set at the end of the animation. If the
                    // animation is cancelled then don't set the final color matrix so the new
                    // animator can pick up from where this one left off.
                    dtm.setColorMatrix(LEVEL_COLOR_MATRIX_NIGHT_DISPLAY, to);
                }
                mColorMatrixAnimator = null;
            }
        });
        mColorMatrixAnimator.start();
    }
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 99 with ValueAnimator

use of android.animation.ValueAnimator in project ExplosionField by tyrantgit.

the class ExplosionField method explode.

public void explode(final View view) {
    Rect r = new Rect();
    view.getGlobalVisibleRect(r);
    int[] location = new int[2];
    getLocationOnScreen(location);
    r.offset(-location[0], -location[1]);
    r.inset(-mExpandInset[0], -mExpandInset[1]);
    int startDelay = 100;
    ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(150);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        Random random = new Random();

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setTranslationX((random.nextFloat() - 0.5f) * view.getWidth() * 0.05f);
            view.setTranslationY((random.nextFloat() - 0.5f) * view.getHeight() * 0.05f);
        }
    });
    animator.start();
    view.animate().setDuration(150).setStartDelay(startDelay).scaleX(0f).scaleY(0f).alpha(0f).start();
    explode(Utils.createBitmapFromView(view), r, startDelay, ExplosionAnimator.DEFAULT_DURATION);
}
Also used : Rect(android.graphics.Rect) Random(java.util.Random) ValueAnimator(android.animation.ValueAnimator)

Example 100 with ValueAnimator

use of android.animation.ValueAnimator in project pictureapp by EyeSeeTea.

the class SwipeDismissListViewTouchListener method performDismiss.

private void performDismiss(final View dismissView, final int dismissPosition) {
    // Animate the dismissed list item to zero-height and fire the dismiss callback when
    // all dismissed list item animations have completed. This triggers layout on each animation
    // frame; in the future we may want to do something smarter and more performant.
    final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
    final int originalHeight = dismissView.getHeight();
    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            --mDismissAnimationRefCount;
            if (mDismissAnimationRefCount == 0) {
                // No active animations, process all pending dismisses.
                // Sort by descending position
                Collections.sort(mPendingDismisses);
                int[] dismissPositions = new int[mPendingDismisses.size()];
                for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
                    dismissPositions[i] = mPendingDismisses.get(i).position;
                }
                mCallbacks.onDismiss(mListView, dismissPositions);
                // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss
                // animation with a stale position
                mDownPosition = ListView.INVALID_POSITION;
                ViewGroup.LayoutParams lp;
                for (PendingDismissData pendingDismiss : mPendingDismisses) {
                    // Reset view presentation
                    pendingDismiss.view.setAlpha(1f);
                    pendingDismiss.view.setTranslationX(0);
                    lp = pendingDismiss.view.getLayoutParams();
                    lp.height = originalHeight;
                    pendingDismiss.view.setLayoutParams(lp);
                }
                // Send a cancel event
                long time = SystemClock.uptimeMillis();
                MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0);
                mListView.dispatchTouchEvent(cancelEvent);
                mPendingDismisses.clear();
            }
        }
    });
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            dismissView.setLayoutParams(lp);
        }
    });
    mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
    animator.start();
}
Also used : Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ValueAnimator(android.animation.ValueAnimator) ViewGroup(android.view.ViewGroup) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator) MotionEvent(android.view.MotionEvent)

Aggregations

ValueAnimator (android.animation.ValueAnimator)1224 Animator (android.animation.Animator)625 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)455 ObjectAnimator (android.animation.ObjectAnimator)187 ArrayList (java.util.ArrayList)128 Paint (android.graphics.Paint)124 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)111 LinearInterpolator (android.view.animation.LinearInterpolator)102 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)91 View (android.view.View)90 AnimatorSet (android.animation.AnimatorSet)87 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)74 ArgbEvaluator (android.animation.ArgbEvaluator)57 ViewGroup (android.view.ViewGroup)44 TextView (android.widget.TextView)44 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)40 PropertyValuesHolder (android.animation.PropertyValuesHolder)36 ImageView (android.widget.ImageView)34 Interpolator (android.view.animation.Interpolator)31 SuppressLint (android.annotation.SuppressLint)25