Example usage for android.animation Keyframe ofInt

List of usage examples for android.animation Keyframe ofInt

Introduction

In this page you can find the example usage for android.animation Keyframe ofInt.

Prototype

public static Keyframe ofInt(float fraction, int value) 

Source Link

Document

Constructs a Keyframe object with the given time and value.

Usage

From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java

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);//  ww  w. ja va  2 s  .  c o m
    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: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.  ja v  a2 s  . com*/
    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:android.support.graphics.drawable.AnimatorInflaterCompat.java

private static Keyframe loadKeyframe(Context context, Resources res, Theme theme, AttributeSet attrs,
        int valueType, XmlPullParser parser) throws XmlPullParserException, IOException {

    TypedArray a = TypedArrayUtils.obtainAttributes(res, theme, attrs, AndroidResources.STYLEABLE_KEYFRAME);

    Keyframe keyframe = null;//  www . j  ava2 s.  c  om

    float fraction = TypedArrayUtils.getNamedFloat(a, parser, "fraction",
            AndroidResources.STYLEABLE_KEYFRAME_FRACTION, -1);

    TypedValue keyframeValue = TypedArrayUtils.peekNamedValue(a, parser, "value",
            AndroidResources.STYLEABLE_KEYFRAME_VALUE);
    boolean hasValue = (keyframeValue != null);
    if (valueType == VALUE_TYPE_UNDEFINED) {
        // When no value type is provided, check whether it's a color type first.
        // If not, fall back to default value type (i.e. float type).
        if (hasValue && isColorType(keyframeValue.type)) {
            valueType = VALUE_TYPE_COLOR;
        } else {
            valueType = VALUE_TYPE_FLOAT;
        }
    }

    if (hasValue) {
        switch (valueType) {
        case VALUE_TYPE_FLOAT:
            float value = TypedArrayUtils.getNamedFloat(a, parser, "value",
                    AndroidResources.STYLEABLE_KEYFRAME_VALUE, 0);
            keyframe = Keyframe.ofFloat(fraction, value);
            break;
        case VALUE_TYPE_COLOR:
        case VALUE_TYPE_INT:
            int intValue = TypedArrayUtils.getNamedInt(a, parser, "value",
                    AndroidResources.STYLEABLE_KEYFRAME_VALUE, 0);
            keyframe = Keyframe.ofInt(fraction, intValue);
            break;
        }
    } else {
        keyframe = (valueType == VALUE_TYPE_FLOAT) ? Keyframe.ofFloat(fraction) : Keyframe.ofInt(fraction);
    }

    final int resID = TypedArrayUtils.getNamedResourceId(a, parser, "interpolator",
            AndroidResources.STYLEABLE_KEYFRAME_INTERPOLATOR, 0);
    if (resID > 0) {
        final Interpolator interpolator = AnimationUtilsCompat.loadInterpolator(context, resID);
        keyframe.setInterpolator(interpolator);
    }
    a.recycle();

    return keyframe;
}

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  w  w .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;
}