android.animation.Keyframe Java Examples

The following examples show how to use android.animation.Keyframe. 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: Utils.java    From BottomSheetPickers with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #2
Source File: AnimationUtils.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Shake the view from left to right
 *
 * @param view
 * @return
 */
public static ObjectAnimator leftRightShake(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}
 
Example #3
Source File: RadialSelectorView.java    From narrate-android 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 #4
Source File: RadialSelectorView.java    From StyleableDateTimePicker with MIT License 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: Utils.java    From PersianDateRangePicker with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 *
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #6
Source File: AnimationUtils.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
public static ObjectAnimator nope(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}
 
Example #7
Source File: RadialSelectorView.java    From AssistantBySDK 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 #8
Source File: Utils.java    From StyleableDateTimePicker with MIT License 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #9
Source File: RadialSelectorView.java    From cathode 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 #10
Source File: Utils.java    From cathode with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #11
Source File: CircleAnimView.java    From customview-samples with Apache License 2.0 6 votes vote down vote up
public void startAnim(){
    if(mValueAnimator!=null&&mValueAnimator.isRunning()){
        return;
    }
    Keyframe k1 = Keyframe.ofFloat(0,mMinSize/2);
    Keyframe k2 = Keyframe.ofFloat(0.5f,mMinSize/4);
    Keyframe k3 = Keyframe.ofFloat(1,mMinSize/2);
    PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("scale",k1,k2,k3);
    mValueAnimator = ValueAnimator.ofPropertyValuesHolder(propertyValuesHolder);
    mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mRadius = (float) animation.getAnimatedValue();
            invalidate();
        }
    });
    mValueAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mValueAnimator.setDuration(2000);
    mValueAnimator.start();
}
 
Example #12
Source File: Utils.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #13
Source File: AnimationUtils.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Shake the view from left to right
 *
 * @param view
 * @return
 */
public static ObjectAnimator leftRightShake(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}
 
Example #14
Source File: Utils.java    From MaterialDateRangePicker with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #15
Source File: Utils.java    From ClockPlus with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #16
Source File: Utils.java    From narrate-android with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #17
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 #18
Source File: RadialSelectorView.java    From MaterialDateRangePicker 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 #19
Source File: Utils.java    From Blackbulb with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #20
Source File: TimeRadialSelectorView.java    From Android-SwitchDateTimePicker 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 #21
Source File: Utils.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #22
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 #23
Source File: RadialSelectorView.java    From date_picker_converter 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 #24
Source File: Utils.java    From AlarmOn with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #25
Source File: Utils.java    From date_picker_converter with Apache License 2.0 6 votes vote down vote up
/**
 * Render an animator to pulsate a view in place.
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
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;
}
 
Example #26
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 #27
Source File: MainActivity.java    From auid2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(final View button) {
    button.setEnabled(false);
    View icon = findViewById(R.id.icon);

    Keyframe keyframe1 = Keyframe.ofFloat(0f, 0f);
    Keyframe keyframe2 = Keyframe.ofFloat(.4f, 90f);
    Keyframe keyframe3 = Keyframe.ofFloat(.6f, 90f);
    Keyframe keyframe4 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("rotation", keyframe1, keyframe2, keyframe3, keyframe4);
    ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(icon, propertyValuesHolder);
    rotationAnim.setDuration(5000);
    rotationAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            button.setEnabled(true);
        }
    });
    rotationAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    rotationAnim.start();
}
 
Example #28
Source File: Views.java    From CameraColorPicker with Apache License 2.0 6 votes vote down vote up
/**
 * Credit goes to Cyril Mottier.
 * https://plus.google.com/+CyrilMottier/posts/FABaJhRMCuy
 *
 * @param view the {@link View} to animate.
 * @return an {@link ObjectAnimator} that will play a 'nope' animation.
 */
public static ObjectAnimator nopeAnimation(View view, int delta) {
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
            Keyframe.ofFloat(0f, 0),
            Keyframe.ofFloat(.10f, -delta),
            Keyframe.ofFloat(.26f, delta),
            Keyframe.ofFloat(.42f, -delta),
            Keyframe.ofFloat(.58f, delta),
            Keyframe.ofFloat(.74f, -delta),
            Keyframe.ofFloat(.90f, delta),
            Keyframe.ofFloat(1f, 0f)
    );

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
            setDuration(500);
}
 
Example #29
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 #30
Source File: RadialSelectorView.java    From AlarmOn 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;
}