Example usage for android.animation ObjectAnimator ofPropertyValuesHolder

List of usage examples for android.animation ObjectAnimator ofPropertyValuesHolder

Introduction

In this page you can find the example usage for android.animation ObjectAnimator ofPropertyValuesHolder.

Prototype

@NonNull
public static ObjectAnimator ofPropertyValuesHolder(Object target, PropertyValuesHolder... values) 

Source Link

Document

Constructs and returns an ObjectAnimator that animates between the sets of values specified in PropertyValueHolder objects.

Usage

From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java

@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);//from w  w w.  j a  v a2s. c om
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}

From source file:io.doist.datetimepicker.time.RadialTimePickerView.java

private static ObjectAnimator getRadiusDisappearAnimator(Object target, String radiusPropertyName,
        InvalidateUpdateListener updateListener, float midRadiusMultiplier, float endRadiusMultiplier) {
    Keyframe kf0, kf1, kf2;/*from  w  w  w .j a v a2s . c  o  m*/
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, midRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, endRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(radiusPropertyName, kf0, kf1, kf2);

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, radiusDisappear)
            .setDuration(duration);
    animator.addUpdateListener(updateListener);
    return animator;
}

From source file:io.doist.datetimepicker.time.RadialTimePickerView.java

private static ObjectAnimator getRadiusReappearAnimator(Object target, String radiusPropertyName,
        InvalidateUpdateListener updateListener, float midRadiusMultiplier, float endRadiusMultiplier) {
    Keyframe kf0, kf1, kf2, kf3;/*from   www .j av a  2s.com*/
    float midwayPoint = 0.2f;
    int duration = 500;

    // 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, endRadiusMultiplier);
    kf1 = Keyframe.ofFloat(delayPoint, endRadiusMultiplier);
    kf2 = Keyframe.ofFloat(midwayPoint, midRadiusMultiplier);
    kf3 = Keyframe.ofFloat(1f, 1);
    PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe(radiusPropertyName, kf0, kf1, kf2,
            kf3);

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, radiusReappear)
            .setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}

From source file:io.doist.datetimepicker.time.RadialTimePickerView.java

private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
        InvalidateUpdateListener updateListener) {
    Keyframe kf0, kf1, kf2;/*from   w ww  .  j a v  a 2 s.c o  m*/
    int duration = 500;

    // 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;

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

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn).setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}