Search in sources :

Example 86 with ObjectAnimator

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

the class StackView method handlePointerUp.

private void handlePointerUp(MotionEvent ev) {
    int pointerIndex = ev.findPointerIndex(mActivePointerId);
    float newY = ev.getY(pointerIndex);
    int deltaY = (int) (newY - mInitialY);
    mLastInteractionTime = System.currentTimeMillis();
    if (mVelocityTracker != null) {
        mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
        mYVelocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
    }
    if (mVelocityTracker != null) {
        mVelocityTracker.recycle();
        mVelocityTracker = null;
    }
    if (deltaY > mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_DOWN && mStackSlider.mMode == StackSlider.NORMAL_MODE) {
        // We reset the gesture variable, because otherwise we will ignore showPrevious() /
        // showNext();
        mSwipeGestureType = GESTURE_NONE;
        // Swipe threshold exceeded, swipe down
        if (mStackMode == ITEMS_SLIDE_UP) {
            showPrevious();
        } else {
            showNext();
        }
        mHighlight.bringToFront();
    } else if (deltaY < -mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_UP && mStackSlider.mMode == StackSlider.NORMAL_MODE) {
        // We reset the gesture variable, because otherwise we will ignore showPrevious() /
        // showNext();
        mSwipeGestureType = GESTURE_NONE;
        // Swipe threshold exceeded, swipe up
        if (mStackMode == ITEMS_SLIDE_UP) {
            showNext();
        } else {
            showPrevious();
        }
        mHighlight.bringToFront();
    } else if (mSwipeGestureType == GESTURE_SLIDE_UP) {
        // Didn't swipe up far enough, snap back down
        int duration;
        float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 1 : 0;
        if (mStackMode == ITEMS_SLIDE_UP || mStackSlider.mMode != StackSlider.NORMAL_MODE) {
            duration = Math.round(mStackSlider.getDurationForNeutralPosition());
        } else {
            duration = Math.round(mStackSlider.getDurationForOffscreenPosition());
        }
        StackSlider animationSlider = new StackSlider(mStackSlider);
        PropertyValuesHolder snapBackY = PropertyValuesHolder.ofFloat("YProgress", finalYProgress);
        PropertyValuesHolder snapBackX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
        ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, snapBackX, snapBackY);
        pa.setDuration(duration);
        pa.setInterpolator(new LinearInterpolator());
        pa.start();
    } else if (mSwipeGestureType == GESTURE_SLIDE_DOWN) {
        // Didn't swipe down far enough, snap back up
        float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 0 : 1;
        int duration;
        if (mStackMode == ITEMS_SLIDE_DOWN || mStackSlider.mMode != StackSlider.NORMAL_MODE) {
            duration = Math.round(mStackSlider.getDurationForNeutralPosition());
        } else {
            duration = Math.round(mStackSlider.getDurationForOffscreenPosition());
        }
        StackSlider animationSlider = new StackSlider(mStackSlider);
        PropertyValuesHolder snapBackY = PropertyValuesHolder.ofFloat("YProgress", finalYProgress);
        PropertyValuesHolder snapBackX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
        ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, snapBackX, snapBackY);
        pa.setDuration(duration);
        pa.start();
    }
    mActivePointerId = INVALID_POINTER;
    mSwipeGestureType = GESTURE_NONE;
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 87 with ObjectAnimator

use of android.animation.ObjectAnimator in project SmartZPN by andforce.

the class GuillotineAnimation method buildOpeningAnimation.

private ObjectAnimator buildOpeningAnimation() {
    ObjectAnimator rotationAnimator = initAnimator(ObjectAnimator.ofFloat(mGuillotineView, ROTATION, GUILLOTINE_CLOSED_ANGLE, GUILLOTINE_OPENED_ANGLE));
    rotationAnimator.setInterpolator(mInterpolator);
    rotationAnimator.setDuration(mDuration);
    rotationAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            mGuillotineView.setVisibility(View.VISIBLE);
            isOpening = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            isOpening = false;
            if (mListener != null) {
                mListener.onGuillotineOpened();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    return rotationAnimator;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator)

Example 88 with ObjectAnimator

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

the class ProgressBar method doRefreshProgress.

private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, boolean callBackToApp, boolean animate) {
    final float scale = mMax > 0 ? progress / (float) mMax : 0;
    final boolean isPrimary = id == R.id.progress;
    if (isPrimary && animate) {
        final ObjectAnimator animator = ObjectAnimator.ofFloat(this, VISUAL_PROGRESS, scale);
        animator.setAutoCancel(true);
        animator.setDuration(PROGRESS_ANIM_DURATION);
        animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR);
        animator.start();
    } else {
        setVisualProgress(id, scale);
    }
    if (isPrimary && callBackToApp) {
        onProgressRefresh(scale, fromUser, progress);
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator)

Example 89 with ObjectAnimator

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

the class ScrollingTabContainerView method animateToVisibility.

public void animateToVisibility(int visibility) {
    if (mVisibilityAnim != null) {
        mVisibilityAnim.cancel();
    }
    if (visibility == VISIBLE) {
        if (getVisibility() != VISIBLE) {
            setAlpha(0);
        }
        ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1);
        anim.setDuration(FADE_DURATION);
        anim.setInterpolator(sAlphaInterpolator);
        anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
        anim.start();
    } else {
        ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0);
        anim.setDuration(FADE_DURATION);
        anim.setInterpolator(sAlphaInterpolator);
        anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
        anim.start();
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator)

Example 90 with ObjectAnimator

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

the class DrawableHolder method startAnimations.

/**
     * Starts all animations added since the last call to this function.  Used to synchronize
     * animations.
     *
     * @param listener an optional listener to add to the animations. Typically used to know when
     * to invalidate the surface these are being drawn to.
     */
public void startAnimations(ValueAnimator.AnimatorUpdateListener listener) {
    for (int i = 0; i < mNeedToStart.size(); i++) {
        ObjectAnimator anim = mNeedToStart.get(i);
        anim.addUpdateListener(listener);
        anim.addListener(this);
        anim.start();
    }
    mNeedToStart.clear();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)791 Animator (android.animation.Animator)313 AnimatorSet (android.animation.AnimatorSet)214 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)208 PropertyValuesHolder (android.animation.PropertyValuesHolder)128 ValueAnimator (android.animation.ValueAnimator)111 View (android.view.View)102 Paint (android.graphics.Paint)68 TextView (android.widget.TextView)49 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)48 ViewGroup (android.view.ViewGroup)45 Rect (android.graphics.Rect)35 LinearInterpolator (android.view.animation.LinearInterpolator)35 ImageView (android.widget.ImageView)31 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)30 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)29 OvershootInterpolator (android.view.animation.OvershootInterpolator)29 ArrayList (java.util.ArrayList)22 TargetApi (android.annotation.TargetApi)21 Interpolator (android.view.animation.Interpolator)20