Search in sources :

Example 56 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project AisenWeiBo by wangdan.

the class PicturePickFragment method switchDireListFragment.

void switchDireListFragment(View v) {
    if (layFileDires.getVisibility() == View.GONE) {
        layFileDires.setVisibility(View.VISIBLE);
    }
    AnimatorSet animSet = new AnimatorSet();
    animSet.setDuration(300);
    PropertyValuesHolder alphaPvh = null;
    PropertyValuesHolder yPvh = null;
    // 切换至隐藏
    if (layFileDireBg.getAlpha() > 0.0f) {
        expandDir = false;
        alphaPvh = PropertyValuesHolder.ofFloat(View.ALPHA, 0.6f, 0.0f);
        yPvh = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0, getRefreshView().getHeight());
    } else {
        expandDir = true;
        alphaPvh = PropertyValuesHolder.ofFloat(View.ALPHA, 0.0f, 0.6f);
        yPvh = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, getRefreshView().getHeight(), 0);
    }
    // 背景视图的动画
    ObjectAnimator alphaAnim = ObjectAnimator.ofPropertyValuesHolder(layFileDireBg, alphaPvh);
    animSet.playTogether(alphaAnim);
    // 文件夹视图的动画
    ObjectAnimator yAnim = ObjectAnimator.ofPropertyValuesHolder(layFileDires, yPvh);
    animSet.playTogether(yAnim);
    animSet.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            if (expandDir)
                layFileDireBg.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            diresFragment.refreshUI();
            if (!expandDir) {
                layFileDireBg.setVisibility(View.GONE);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animSet.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) AnimatorSet(android.animation.AnimatorSet)

Example 57 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project AisenWeiBo by wangdan.

the class Utils method getPulseAnimator.

public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) {
    Keyframe k0 = Keyframe.ofFloat(0f, 1f);
    Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
    Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
    Keyframe k3 = Keyframe.ofFloat(1f, 1f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
    ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
    pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
    return pulseAnimator;
}
Also used : Keyframe(android.animation.Keyframe) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 58 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project AisenWeiBo by wangdan.

the class RadialSelectorView method getReappearAnimator.

public ObjectAnimator getReappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }
    Keyframe kf0, kf1, kf2, kf3;
    float midwayPoint = 0.2f;
    int duration = 500;
    // The time points are half of what they would normally be, because this animation is
    // staggered against the disappear so they happen seamlessly. The reappear starts
    // halfway into the disappear.
    float delayMultiplier = 0.25f;
    float transitionDurationMultiplier = 1f;
    float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    int totalDuration = (int) (duration * totalDurationMultiplier);
    float delayPoint = (delayMultiplier * duration) / totalDuration;
    midwayPoint = 1 - (midwayPoint * (1 - delayPoint));
    kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier);
    kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier);
    kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf3 = Keyframe.ofFloat(1f, 1);
    PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3);
    kf0 = Keyframe.ofFloat(0f, 0f);
    kf1 = Keyframe.ofFloat(delayPoint, 0f);
    kf2 = Keyframe.ofFloat(1f, 1f);
    PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
    ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration);
    reappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    return reappearAnimator;
}
Also used : Keyframe(android.animation.Keyframe) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 59 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project AisenWeiBo by wangdan.

the class RadialTextsView method renderAnimations.

/**
     * Render the animations for appearing and disappearing.
     */
private void renderAnimations() {
    Keyframe kf0, kf1, kf2, kf3;
    float midwayPoint = 0.2f;
    int duration = 500;
    // Set up animator for disappearing.
    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);
    mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration);
    mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    // Set up animator for reappearing.
    float delayMultiplier = 0.25f;
    float transitionDurationMultiplier = 1f;
    float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    int totalDuration = (int) (duration * totalDurationMultiplier);
    float delayPoint = (delayMultiplier * duration) / totalDuration;
    midwayPoint = 1 - (midwayPoint * (1 - delayPoint));
    kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier);
    kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier);
    kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf3 = Keyframe.ofFloat(1f, 1);
    PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3);
    kf0 = Keyframe.ofFloat(0f, 0f);
    kf1 = Keyframe.ofFloat(delayPoint, 0f);
    kf2 = Keyframe.ofFloat(1f, 1f);
    PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
    mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration);
    mReappearAnimator.addUpdateListener(mInvalidateUpdateListener);
}
Also used : Keyframe(android.animation.Keyframe) PropertyValuesHolder(android.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 60 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project SublimePicker by vikramkakkar.

the class RadialTimePickerView method getFadeInAnimator.

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;
}
Also used : Keyframe(android.animation.Keyframe) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Aggregations

PropertyValuesHolder (android.animation.PropertyValuesHolder)210 ObjectAnimator (android.animation.ObjectAnimator)144 Animator (android.animation.Animator)96 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)70 ValueAnimator (android.animation.ValueAnimator)64 Paint (android.graphics.Paint)33 AnimatorSet (android.animation.AnimatorSet)25 NonNull (android.support.annotation.NonNull)18 LinearInterpolator (android.view.animation.LinearInterpolator)18 Interpolator (android.view.animation.Interpolator)16 ArrayList (java.util.ArrayList)16 ViewGroup (android.view.ViewGroup)14 View (android.view.View)12 IntEvaluator (android.animation.IntEvaluator)11 Point (android.graphics.Point)11 Keyframe (android.animation.Keyframe)10 TimeAnimator (android.animation.TimeAnimator)10 Path (android.graphics.Path)10 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)8 Rect (android.graphics.Rect)7