android.animation.PropertyValuesHolder Java Examples

The following examples show how to use android.animation.PropertyValuesHolder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RadialTimePickerView.java    From AppCompat-Extension-Library with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
                                                InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}
 
Example #2
Source File: FragmentManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
static boolean modifiesAlpha(Animator anim) {
    if (anim == null) {
        return false;
    }
    if (anim instanceof ValueAnimator) {
        ValueAnimator valueAnim = (ValueAnimator) anim;
        PropertyValuesHolder[] values = valueAnim.getValues();
        for (int i = 0; i < values.length; i++) {
            if (("alpha").equals(values[i].getPropertyName())) {
                return true;
            }
        }
    } else if (anim instanceof AnimatorSet) {
        List<Animator> animList = ((AnimatorSet) anim).getChildAnimations();
        for (int i = 0; i < animList.size(); i++) {
            if (modifiesAlpha(animList.get(i))) {
                return true;
            }
        }
    }
    return false;
}
 
Example #3
Source File: Swing.java    From Flubber with Apache License 2.0 6 votes vote down vote up
@Override
public Animator getAnimationFor(AnimationBody animationBody, View view) {
    final float force = animationBody.getForce();

    float[] values = {
            (float) Math.toDegrees(0),
            (float) Math.toDegrees(0.3f * force),
            (float) Math.toDegrees(-0.3f * force),
            (float) Math.toDegrees(0.3f * force),
            (float) Math.toDegrees(0f),
            (float) Math.toDegrees(0f)
    };

    final PropertyValuesHolder pvhRotation =
            PropertyValuesHolder.ofKeyframe(View.ROTATION, KeyFrameUtil.getKeyFrames(Flubber.FRACTIONS, values));

    final ObjectAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, pvhRotation);

    return animation;
}
 
Example #4
Source File: RadialSelectorView.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
Example #5
Source File: DragState.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private ValueAnimator createCancelAnimationLocked() {
    final ValueAnimator animator = ValueAnimator.ofPropertyValuesHolder(
            PropertyValuesHolder.ofFloat(
                    ANIMATED_PROPERTY_X, mCurrentX - mThumbOffsetX, mCurrentX),
            PropertyValuesHolder.ofFloat(
                    ANIMATED_PROPERTY_Y, mCurrentY - mThumbOffsetY, mCurrentY),
            PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_SCALE, 1, 0),
            PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_ALPHA, mOriginalAlpha, 0));
    final AnimationListener listener = new AnimationListener();
    animator.setDuration(MIN_ANIMATION_DURATION_MS);
    animator.setInterpolator(mCubicEaseOutInterpolator);
    animator.addListener(listener);
    animator.addUpdateListener(listener);

    mService.mAnimationHandler.post(() -> animator.start());
    return animator;
}
 
Example #6
Source File: DefaultCardStreamAnimator.java    From android-play-places with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@Override
public ObjectAnimator getAppearingAnimator(Context context){

    final Point outPoint = new Point();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getSize(outPoint);

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(new Object(),
            PropertyValuesHolder.ofFloat("alpha", 0.f, 1.f),
            PropertyValuesHolder.ofFloat("translationY", outPoint.y / 2.f, 0.f),
            PropertyValuesHolder.ofFloat("rotation", -45.f, 0.f));

    animator.setDuration((long) (200 * mSpeedFactor));
    return animator;
}
 
Example #7
Source File: CustormAnim.java    From LiveGiftLayout with Apache License 2.0 6 votes vote down vote up
@NonNull
    private AnimatorSet testAnim(GiftFrameLayout giftFrameLayout) {
        PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0, -50);
        PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.5f);
        ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator.setStartDelay(0);
        animator.setDuration(1500);

        translationY = PropertyValuesHolder.ofFloat("translationY", -50, -100);
        alpha = PropertyValuesHolder.ofFloat("alpha", 0.5f, 0f);
        ObjectAnimator animator1 = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator1.setStartDelay(0);
        animator1.setDuration(1500);

        // 复原
//        ObjectAnimator fadeAnimator2 = GiftAnimationUtil.createFadeAnimator(giftFrameLayout, 0, 0, 0, 0);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(animator1).after(animator);
//        animatorSet.play(fadeAnimator2).after(animator1);
        animatorSet.start();
        return animatorSet;
    }
 
Example #8
Source File: ExtendedFloatingActionButton.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public AnimatorSet createAnimator() {
  MotionSpec spec = getCurrentMotionSpec();
  if (spec.hasPropertyValues("width")) {
    PropertyValuesHolder[] widthValues = spec.getPropertyValues("width");
    widthValues[0].setFloatValues(getWidth(), size.getWidth());
    spec.setPropertyValues("width", widthValues);
  }

  if (spec.hasPropertyValues("height")) {
    PropertyValuesHolder[] heightValues = spec.getPropertyValues("height");
    heightValues[0].setFloatValues(getHeight(), size.getHeight());
    spec.setPropertyValues("height", heightValues);
  }

  return super.createAnimator(spec);
}
 
Example #9
Source File: LiveRoomActivity.java    From XPlayer2 with Apache License 2.0 6 votes vote down vote up
private void scale(float ratio) {
    if (scaleRatio == ratio) {
        return;
    }

    if (scaleAnimator != null) {
        scaleAnimator.cancel();
    }

    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", scaleRatio, ratio);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", scaleRatio, ratio);
    PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat("translationX", 0);
    PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0);
    scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mVideoView, scaleX, scaleY, translationX, translationY);
    scaleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            animation.removeAllListeners();
            scaleAnimator = null;
        }
    });
    scaleAnimator.setDuration(150L).start();
    scaleRatio = ratio;
}
 
Example #10
Source File: RadialTimePickerView.java    From SublimePicker with Apache License 2.0 6 votes vote down vote up
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
                                                InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}
 
Example #11
Source File: ScaleDownAnimation.java    From Android-Image-Slider with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) {
	String propertyName;
	int startRadiusValue;
	int endRadiusValue;

	if (isReverse) {
		propertyName = ANIMATION_SCALE_REVERSE;
		startRadiusValue = (int) (radius * scaleFactor);
		endRadiusValue = radius;
	} else {
		propertyName = ANIMATION_SCALE;
		startRadiusValue = radius;
		endRadiusValue = (int) (radius * scaleFactor);
	}

	PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue);
	holder.setEvaluator(new IntEvaluator());

	return holder;
}
 
Example #12
Source File: ScaleAnimation.java    From Android-Image-Slider with Apache License 2.0 6 votes vote down vote up
@NonNull
protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) {
    String propertyName;
    int startRadiusValue;
    int endRadiusValue;

    if (isReverse) {
        propertyName = ANIMATION_SCALE_REVERSE;
        startRadiusValue = radius;
        endRadiusValue = (int) (radius * scaleFactor);
    } else {
        propertyName = ANIMATION_SCALE;
        startRadiusValue = (int) (radius * scaleFactor);
        endRadiusValue = radius;
    }

    PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue);
    holder.setEvaluator(new IntEvaluator());

    return holder;
}
 
Example #13
Source File: MainActivity.java    From Android-SecretCodes with Apache License 2.0 6 votes vote down vote up
private static ObjectAnimator tada(final View view, final float shakeFactor) {
    final PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f),
            Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f),
            Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f));

    final PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f),
            Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f),
            Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f));

    final PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f),
            Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor), Keyframe.ofFloat(.3f, 3f * shakeFactor),
            Keyframe.ofFloat(.4f, -3f * shakeFactor), Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor),
            Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor), Keyframe.ofFloat(.9f, 3f * shakeFactor),
            Keyframe.ofFloat(1f, 0));

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(1000);
}
 
Example #14
Source File: RadialSelectorView.java    From Blackbulb with GNU General Public License v3.0 6 votes vote down vote up
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
Example #15
Source File: AnimatedNotificationDisplayActivity.java    From AndroidWearable-Samples with Apache License 2.0 6 votes vote down vote up
private void createNextAnimation(boolean start) {
    float startX = mImageView.getTranslationX();
    float startY = mImageView.getTranslationY();
    float endX = -mRandom.nextInt(mAnimationRange);
    float endY = -mRandom.nextInt(mAnimationRange);
    float distance = (float) Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));

    mAnimation = ObjectAnimator.ofPropertyValuesHolder(mImageView,
            PropertyValuesHolder.ofFloat("translationX", startX, endX),
            PropertyValuesHolder.ofFloat("translationY", startY, endY));
    mAnimation.setInterpolator(new AccelerateDecelerateInterpolator());

    mAnimation.setDuration(Math.max(BASE_ANIMATION_DURATION_MS / 10,
            (int) (distance * BASE_ANIMATION_DURATION_MS / mAnimationRange)));

    mAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            createNextAnimation(true);
        }
    });
    if (start) {
        mAnimation.start();
    }
}
 
Example #16
Source File: Tooltip.java    From NBAPlus with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param values
 * @return
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public ObjectAnimator setEnterAnimation(PropertyValuesHolder... values){

    for(PropertyValuesHolder value: values){

        if(value.getPropertyName().equals("alpha"))
            setAlpha(0);
        if(value.getPropertyName().equals("rotation"))
            setRotation(0);
        if(value.getPropertyName().equals("rotationX"))
            setRotationX(0);
        if(value.getPropertyName().equals("rotationY"))
            setRotationY(0);
        if(value.getPropertyName().equals("translationX"))
            setTranslationX(0);
        if(value.getPropertyName().equals("translationY"))
            setTranslationY(0);
        if(value.getPropertyName().equals("scaleX"))
            setScaleX(0);
        if(value.getPropertyName().equals("scaleY"))
            setScaleY(0);
    }
    return mEnterAnimator =  ObjectAnimator.ofPropertyValuesHolder(this, values);
}
 
Example #17
Source File: TranslationHideAnimator2.java    From AndroidSkinAnimator with MIT License 6 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationY", 0, view.getHeight()));
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
Example #18
Source File: FragmentTransactionExtended.java    From Kernel-Tuner with GNU General Public License v3.0 6 votes vote down vote up
public void slideForward() {
    View movingFragmentView = mFirstFragment.getView();
    PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationX", 40f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1f);
    ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX, scaleX, scaleY, alpha);

    ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationX", 0);
    movingFragmentRotator.setStartDelay(mContext.getResources().getInteger(R.integer.half_slide_up_down_duration));

    AnimatorSet s = new AnimatorSet();
    s.playTogether(movingFragmentAnimator, movingFragmentRotator);
    s.setStartDelay(mContext.getResources().getInteger(R.integer.slide_up_down_duration));
    s.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mIsAnimating = false;
            mDidSlideOut = true;
        }
    });
    s.start();
    ((Activity) this.mContext).getFragmentManager().removeOnBackStackChangedListener(this);
}
 
Example #19
Source File: TranslationAnimator2.java    From AndroidSkinAnimator with MIT License 6 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
    this.targetView = view;
    preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("translationX",
                    view.getLeft(), view.getRight()))
            .setDuration(PRE_DURATION * 3);
    preAnimator.setInterpolator(new AccelerateInterpolator());
    afterAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("translationX",
                    view.getLeft() - view.getWidth(), view.getLeft()))
            .setDuration(AFTER_DURATION * 3);
    afterAnimator.setInterpolator(new BounceInterpolator());

    preAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (action != null) {
                action.action();
            }
            afterAnimator.start();
        }
    });
    return this;
}
 
Example #20
Source File: MD360PlayerActivity.java    From MD360Player4Android with Apache License 2.0 6 votes vote down vote up
private void startCameraAnimation(final MDDirectorCamUpdate cameraUpdate, PropertyValuesHolder... values){
    if (animator != null){
        animator.cancel();
    }

    animator = ValueAnimator.ofPropertyValuesHolder(values).setDuration(2000);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float near = (float) animation.getAnimatedValue("near");
            float eyeZ = (float) animation.getAnimatedValue("eyeZ");
            float pitch = (float) animation.getAnimatedValue("pitch");
            float yaw = (float) animation.getAnimatedValue("yaw");
            float roll = (float) animation.getAnimatedValue("roll");
            cameraUpdate.setEyeZ(eyeZ).setNearScale(near).setPitch(pitch).setYaw(yaw).setRoll(roll);
        }
    });
    animator.start();
}
 
Example #21
Source File: EnterScreenAnimations.java    From YCGallery with Apache License 2.0 6 votes vote down vote up
/**
 * This method creates an animator that changes ImageView position on the screen.
 * It will look like view is translated from its position on previous screen to its new position on this screen
 */
@NonNull
private ObjectAnimator createEnteringImagePositionAnimator() {
    PropertyValuesHolder propertyLeft = PropertyValuesHolder.ofInt("left", mAnimatedImage.getLeft(), mToLeft);
    PropertyValuesHolder propertyTop = PropertyValuesHolder.ofInt("top", mAnimatedImage.getTop(), mToTop - getStatusBarHeight());

    PropertyValuesHolder propertyRight = PropertyValuesHolder.ofInt("right", mAnimatedImage.getRight(), mToLeft + mToWidth);
    PropertyValuesHolder propertyBottom = PropertyValuesHolder.ofInt("bottom", mAnimatedImage.getBottom(), mToTop + mToHeight - getStatusBarHeight());

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mAnimatedImage, propertyLeft, propertyTop, propertyRight, propertyBottom);
    animator.addListener(new SimpleAnimationListener() {
        @Override
        public void onAnimationEnd(Animator animation) {
            // set new parameters of animated ImageView. This will prevent blinking of view when set visibility to visible in Exit animation
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mAnimatedImage.getLayoutParams();
            layoutParams.height = mImageTo.getHeight();
            layoutParams.width = mImageTo.getWidth();
            layoutParams.setMargins(mToLeft, mToTop - getStatusBarHeight(), 0, 0);
        }
    });
    return animator;
}
 
Example #22
Source File: TranslationAnimator.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
    this.targetView = view;
    preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationX",
                    view.getLeft(), view.getRight()))
            .setDuration(PRE_DURATION * 3);
    preAnimator.setInterpolator(new AnticipateInterpolator());
    afterAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("translationX",
                    view.getRight(), view.getLeft()))
            .setDuration(AFTER_DURATION * 2);
    afterAnimator.setInterpolator(new BounceInterpolator());

    preAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            targetView.setAlpha(1);
            if (action != null) {
                action.action();
            }
            afterAnimator.start();
        }
    });
    return this;
}
 
Example #23
Source File: TypedAction.java    From AndroidAnimationsActions with MIT License 5 votes vote down vote up
private void prepareScaleAnimation(boolean scaleBy) {
    float scaleXOffset = scaleBy ? view.getScaleX() : 0;
    float scaleYOffset = scaleBy ? view.getScaleY() : 0;
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", view.getScaleX(), scaleXOffset + floatTargets[0]);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", view.getScaleY(), scaleYOffset + floatTargets[1]);
    setValues(scaleX, scaleY);
    addUpdateListener(new ScaleUpdateListener(view));
}
 
Example #24
Source File: SlideInAnimationHandler.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Override
    public void animateMenuOpening(Point center) {
        super.animateMenuOpening(center);

        setAnimating(true);

        Animator lastAnimation = null;
        for (int i = 0; i < menu.getSubActionItems().size(); i++) {

            menu.getSubActionItems().get(i).view.setAlpha(0);

            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) menu.getSubActionItems().get(i).view.getLayoutParams();
            params.setMargins(menu.getSubActionItems().get(i).x, menu.getSubActionItems().get(i).y + DIST_Y, 0, 0);
            menu.getSubActionItems().get(i).view.setLayoutParams(params);

//            PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, menu.getSubActionItems().get(i).x/* - center.x + menu.getSubActionItems().get(i).width / 2*/);
            PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -DIST_Y);
//            PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
//            PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
            PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 1);

            final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhY, pvhA);
            animation.setDuration(DURATION);
            animation.setInterpolator(new DecelerateInterpolator());
            animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.OPENING));

            if(i == 0) {
                lastAnimation = animation;
            }

            animation.setStartDelay(Math.abs(menu.getSubActionItems().size()/2-i) * LAG_BETWEEN_ITEMS);
            animation.start();
        }
        if(lastAnimation != null) {
            lastAnimation.addListener(new LastAnimationListener());
        }

    }
 
Example #25
Source File: SlideInAnimationHandler.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
    public void animateMenuClosing(Point center) {
        super.animateMenuOpening(center);

        setAnimating(true);

        Animator lastAnimation = null;
        for (int i = 0; i < menu.getSubActionItems().size(); i++) {
//            PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, - (menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2));
            PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, DIST_Y);
//            PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
//            PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
            PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 0);

            final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhY, pvhA);
            animation.setDuration(DURATION);
            animation.setInterpolator(new AccelerateInterpolator());
            animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.CLOSING));

            if(i == 0) {
                lastAnimation = animation;
            }

            if(i <= menu.getSubActionItems().size()/2) {
                animation.setStartDelay(i * LAG_BETWEEN_ITEMS);
            }
            else {
                animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
            }
            animation.start();
        }
        if(lastAnimation != null) {
            lastAnimation.addListener(new LastAnimationListener());
        }
    }
 
Example #26
Source File: SlideInAnimationHandler.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Override
    public void animateMenuClosing(Point center) {
        super.animateMenuOpening(center);

        setAnimating(true);

        Animator lastAnimation = null;
        for (int i = 0; i < menu.getSubActionItems().size(); i++) {
//            PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, - (menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2));
            PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, DIST_Y);
//            PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
//            PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
            PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 0);

            final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhY, pvhA);
            animation.setDuration(DURATION);
            animation.setInterpolator(new AccelerateInterpolator());
            animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.CLOSING));

            if(i == 0) {
                lastAnimation = animation;
            }

            if(i <= menu.getSubActionItems().size()/2) {
                animation.setStartDelay(i * LAG_BETWEEN_ITEMS);
            }
            else {
                animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
            }
            animation.start();
        }
        if(lastAnimation != null) {
            lastAnimation.addListener(new LastAnimationListener());
        }
    }
 
Example #27
Source File: LauncherAnimUtils.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
public static ObjectAnimator ofPropertyValuesHolder(View target,
        PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setValues(values);
    cancelOnDestroyActivity(anim);
    new FirstFrameAnimatorHelper(anim, target);
    return anim;
}
 
Example #28
Source File: CustomAnimationActivity.java    From Reachability with Apache License 2.0 5 votes vote down vote up
private PropertyValuesHolder[] fromLeftAnimation() {

        PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat( "translationX", -getWidth(), 0f );
        PropertyValuesHolder holderR = PropertyValuesHolder.ofFloat("rotation", 0f, 360f);
        PropertyValuesHolder[] holders = {holderX, holderR};
        return holders;
    }
 
Example #29
Source File: DynamicRoundTextView.java    From customview-samples with Apache License 2.0 5 votes vote down vote up
private Animator buildDisappearAnimator(){
    Keyframe k0 = Keyframe.ofFloat(0f, 1);
    Keyframe k1 = Keyframe.ofFloat(0.5f, 0.5f);
    Keyframe k2 = Keyframe.ofFloat(1f, 0);
    PropertyValuesHolder widthValuesHolder = PropertyValuesHolder.ofKeyframe(View.SCALE_X, k0,k1,k2);
    PropertyValuesHolder heightValuesHolder = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, k0,k1,k2);

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(this,widthValuesHolder,heightValuesHolder);
    animator.setDuration(TIME_DURING_CLOSE_TO_DISAPPEAR);
    return animator;
}
 
Example #30
Source File: FlipTransitionFactory.java    From android-slideshow-widget with Apache License 2.0 5 votes vote down vote up
@Override
public Animator getInAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) {
    target.setAlpha(1);
    target.setScaleX(1);
    target.setScaleY(1);
    target.setTranslationX(0);
    target.setTranslationY(0);

    final PropertyValuesHolder rotation;
    final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0, 1);

    switch (axis) {
        case VERTICAL:
            target.setRotationX(-90);
            target.setRotationY(0);
            rotation = PropertyValuesHolder.ofFloat(View.ROTATION_X, 0);
            break;

        case HORIZONTAL:
        default:
            target.setRotationX(0);
            target.setRotationY(-90);
            rotation = PropertyValuesHolder.ofFloat(View.ROTATION_Y, 0);
            break;
    }

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, rotation/*, alpha*/);
    animator.setDuration(getDuration()/2);
    animator.setStartDelay(getDuration()/2);
    animator.setInterpolator(getInterpolator());

    return animator;
}