Search in sources :

Example 36 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project MultiPhotoPicker by wangeason.

the class ImagePagerFragment method runEnterAnimation.

/**
   * The enter animation scales the picture in from its previous thumbnail
   * size/location, colorizing it in parallel. In parallel, the background of the
   * activity is fading in. When the pictue is in place, the text description
   * drops down.
   */
private void runEnterAnimation() {
    final long duration = ANIM_DURATION;
    // Set starting values for properties we're going to animate. These
    // values scale and position the full size version down to the thumbnail
    // size/location, from which we'll animate it back up
    ViewHelper.setPivotX(mViewPager, 0);
    ViewHelper.setPivotY(mViewPager, 0);
    ViewHelper.setScaleX(mViewPager, (float) thumbnailWidth / mViewPager.getWidth());
    ViewHelper.setScaleY(mViewPager, (float) thumbnailHeight / mViewPager.getHeight());
    ViewHelper.setTranslationX(mViewPager, thumbnailLeft);
    ViewHelper.setTranslationY(mViewPager, thumbnailTop);
    // Animate scale and translation to go from thumbnail to full size
    ViewPropertyAnimator.animate(mViewPager).setDuration(duration).scaleX(1).scaleY(1).translationX(0).translationY(0).setInterpolator(new DecelerateInterpolator());
    // Fade in the black background
    ObjectAnimator bgAnim = ObjectAnimator.ofInt(mViewPager.getBackground(), "alpha", 0, 255);
    bgAnim.setDuration(duration);
    bgAnim.start();
    // Animate a color filter to take the image from grayscale to full color.
    // This happens in parallel with the image scaling and moving into place.
    ObjectAnimator colorizer = ObjectAnimator.ofFloat(ImagePagerFragment.this, "saturation", 0, 1);
    colorizer.setDuration(duration);
    colorizer.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 37 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project MultiPhotoPicker by wangeason.

the class ImagePagerFragment method runExitAnimation.

/**
   * The exit animation is basically a reverse of the enter animation, except that if
   * the orientation has changed we simply scale the picture back into the center of
   * the screen.
   *
   * @param endAction This action gets run after the animation completes (this is
   * when we actually switch activities)
   */
public void runExitAnimation(final Runnable endAction) {
    if (!getArguments().getBoolean(ARG_HAS_ANIM, false) || !hasAnim) {
        endAction.run();
        return;
    }
    final long duration = ANIM_DURATION;
    // Animate image back to thumbnail size/location
    ViewPropertyAnimator.animate(mViewPager).setDuration(duration).setInterpolator(new AccelerateInterpolator()).scaleX((float) thumbnailWidth / mViewPager.getWidth()).scaleY((float) thumbnailHeight / mViewPager.getHeight()).translationX(thumbnailLeft).translationY(thumbnailTop).setListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            endAction.run();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    // Fade out background
    ObjectAnimator bgAnim = ObjectAnimator.ofInt(mViewPager.getBackground(), "alpha", 0);
    bgAnim.setDuration(duration);
    bgAnim.start();
    // Animate a color filter to take the image back to grayscale,
    // in parallel with the image scaling and moving into place.
    ObjectAnimator colorizer = ObjectAnimator.ofFloat(ImagePagerFragment.this, "saturation", 1, 0);
    colorizer.setDuration(duration);
    colorizer.start();
}
Also used : Animator(com.nineoldandroids.animation.Animator) ViewPropertyAnimator(com.nineoldandroids.view.ViewPropertyAnimator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 38 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project AisenWeiBo by wangdan.

the class ViewAnimationUtils method createCircularReveal.

/**
     * Returns an Animator which can animate a clipping circle.
     * <p>
     * Any shadow cast by the View will respect the circular clip from this animator.
     * <p>
     * Only a single non-rectangular clip can be applied on a View at any time.
     * Views clipped by a circular reveal animation take priority over
     * {@link View#setClipToOutline(boolean) View Outline clipping}.
     * <p>
     * Note that the animation returned here is a one-shot animation. It cannot
     * be re-used, and once started it cannot be paused or resumed.
     *
     * @param view The View will be clipped to the animating circle.
     * @param centerX The x coordinate of the center of the animating circle.
     * @param centerY The y coordinate of the center of the animating circle.
     * @param startRadius The starting radius of the animating circle.
     * @param endRadius The ending radius of the animating circle.
     */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) {
    if (!(view.getParent() instanceof RevealAnimator)) {
        throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout.");
    }
    RevealAnimator revealLayout = (RevealAnimator) view.getParent();
    revealLayout.attachRevealInfo(new RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view)));
    if (LOLLIPOP_PLUS) {
        return new SupportAnimatorLollipop(android.view.ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout);
    }
    ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, startRadius, endRadius);
    reveal.addListener(getRevealFinishListener(revealLayout));
    return new SupportAnimatorPreL(reveal, revealLayout);
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) WeakReference(java.lang.ref.WeakReference) RevealInfo(org.aisen.weibo.sina.ui.widget.io.codetail.animation.RevealAnimator.RevealInfo) TargetApi(android.annotation.TargetApi)

Example 39 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project XhsEmoticonsKeyboard by w446108264.

the class AnimEmoticonsIndicatorView method playTo.

public void playTo(int position, PageSetEntity pageSetEntity) {
    if (!checkPageSetEntity(pageSetEntity)) {
        return;
    }
    updateIndicatorCount(pageSetEntity.getPageCount());
    for (ImageView iv : mImageViews) {
        iv.setImageDrawable(mDrawableNomal);
    }
    mImageViews.get(position).setImageDrawable(mDrawableSelect);
    final ImageView imageViewStrat = mImageViews.get(position);
    ObjectAnimator animIn1 = ObjectAnimator.ofFloat(imageViewStrat, "scaleX", 0.25f, 1.0f);
    ObjectAnimator animIn2 = ObjectAnimator.ofFloat(imageViewStrat, "scaleY", 0.25f, 1.0f);
    if (mPlayToAnimatorSet != null && mPlayToAnimatorSet.isRunning()) {
        mPlayToAnimatorSet.cancel();
        mPlayToAnimatorSet = null;
    }
    mPlayToAnimatorSet = new AnimatorSet();
    mPlayToAnimatorSet.play(animIn1).with(animIn2);
    mPlayToAnimatorSet.setDuration(100);
    mPlayToAnimatorSet.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) ImageView(android.widget.ImageView)

Example 40 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project PersistentSearch by KieronQuinn.

the class ViewAnimationUtils method createCircularReveal.

/**
     * Returns an Animator which can animate a clipping circle.
     * <p>
     * Any shadow cast by the View will respect the circular clip from this animator.
     * <p>
     * Only a single non-rectangular clip can be applied on a View at any time.
     * Views clipped by a circular reveal animation take priority over
     * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}.
     * <p>
     * Note that the animation returned here is a one-shot animation. It cannot
     * be re-used, and once started it cannot be paused or resumed.
     *
     * @param view The View will be clipped to the animating circle.
     * @param centerX The x coordinate of the center of the animating circle.
     * @param centerY The y coordinate of the center of the animating circle.
     * @param startRadius The starting radius of the animating circle.
     * @param endRadius The ending radius of the animating circle.
     */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) {
    if (LOLLIPOP_PLUS) {
        return new SupportAnimatorLollipop(android.view.ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius));
    }
    if (!(view.getParent() instanceof RevealAnimator)) {
        throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout.");
    }
    RevealAnimator revealLayout = (RevealAnimator) view.getParent();
    revealLayout.setTarget(view);
    revealLayout.setCenter(centerX, centerY);
    Rect bounds = new Rect();
    view.getHitRect(bounds);
    ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius);
    reveal.addListener(getRevealFinishListener(revealLayout, bounds));
    return new SupportAnimatorPreL(reveal);
}
Also used : Rect(android.graphics.Rect) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) TargetApi(android.annotation.TargetApi)

Aggregations

ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)81 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)27 Animator (com.nineoldandroids.animation.Animator)20 View (android.view.View)11 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)10 Keyframe (com.nineoldandroids.animation.Keyframe)9 Paint (android.graphics.Paint)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 TextView (android.widget.TextView)5 AdapterView (android.widget.AdapterView)4 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)3 SupportAnimator (io.codetail.animation.SupportAnimator)3