Search in sources :

Example 41 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project android-shapeLoadingView by zzz40500.

the class LoadingView method upThrow.

/**
 * 上抛
 */
public void upThrow() {
    if (mUpAnimatorSet == null) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mShapeLoadingView, "translationY", mDistance, 0);
        ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(mIndicationIm, "scaleX", 1f, 0.2f);
        ObjectAnimator objectAnimator1 = null;
        switch(mShapeLoadingView.getShape()) {
            case SHAPE_RECT:
                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
                break;
            case SHAPE_CIRCLE:
                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
                break;
            case SHAPE_TRIANGLE:
                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
                break;
        }
        mUpAnimatorSet = new AnimatorSet();
        mUpAnimatorSet.playTogether(objectAnimator, objectAnimator1, scaleIndication);
        mUpAnimatorSet.setDuration(ANIMATION_DURATION);
        mUpAnimatorSet.setInterpolator(new DecelerateInterpolator(FACTOR));
        mUpAnimatorSet.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!mStopped) {
                    freeFall();
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
    }
    mUpAnimatorSet.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 42 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project PhotoPicker by donglua.

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 43 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project PhotoPicker by donglua.

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 44 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Meizhi by drakeet.

the class FloatView method translationX.

public void translationX(float fromX, float toX, float formAlpha, final float toAlpha) {
    ObjectAnimator a1 = ObjectAnimator.ofFloat(rootView, "alpha", formAlpha, toAlpha);
    ObjectAnimator a2 = ObjectAnimator.ofFloat(rootView, "translationX", fromX, toX);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(a1, a2);
    animatorSet.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (toAlpha == 0) {
                HeadsUpManager.getInstant(getContext()).dismiss();
                cutDown = -1;
                if (velocityTracker != null) {
                    velocityTracker.clear();
                    try {
                        velocityTracker.recycle();
                    } catch (IllegalStateException e) {
                    }
                }
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animatorSet.start();
}
Also used : Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 45 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Meizhi by drakeet.

the class HeadsUpManager method show.

private void show(HeadsUp headsUp) {
    floatView = new FloatView(context, 20);
    WindowManager.LayoutParams params = FloatView.winParams;
    params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.WRAP_CONTENT;
    params.format = -3;
    params.gravity = Gravity.CENTER | Gravity.TOP;
    params.x = floatView.originalLeft;
    params.y = 0;
    params.alpha = 1f;
    wmOne.addView(floatView, params);
    ObjectAnimator a = ObjectAnimator.ofFloat(floatView.rootView, "translationY", -700, 0);
    a.setDuration(600);
    a.start();
    floatView.setNotification(headsUp);
    if (headsUp.getNotification() != null) {
        notificationManager.notify(headsUp.getCode(), headsUp.getNotification());
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) WindowManager(android.view.WindowManager)

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