Search in sources :

Example 6 with PropertyValuesHolder

use of com.nineoldandroids.animation.PropertyValuesHolder in project HoloEverywhere by Prototik.

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;
    kf0 = Keyframe.ofFloat(0f, 0f);
    kf1 = Keyframe.ofFloat(1f, 1f);
    PropertyValuesHolder fade = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
    ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, fade).setDuration(300);
    reappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    return reappearAnimator;
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

Example 7 with PropertyValuesHolder

use of com.nineoldandroids.animation.PropertyValuesHolder in project HoloEverywhere by Prototik.

the class RadialTextsView method renderAnimations.

/**
     * Render the animations for appearing and disappearing.
     */
private void renderAnimations() {
    Keyframe kf0, kf1;
    // Set up animator for disappearing.
    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0.8f);
    PropertyValuesHolder radius = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1);
    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fade = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
    kf0 = Keyframe.ofFloat(0f, 0f);
    kf1 = Keyframe.ofFloat(1f, 70f);
    PropertyValuesHolder rotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1);
    mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radius, fade, rotation).setDuration(300);
    mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    // Set up animator for reappearing.
    kf0 = Keyframe.ofFloat(0f, 0.8f);
    kf1 = Keyframe.ofFloat(1f, 1f);
    radius = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1);
    kf0 = Keyframe.ofFloat(0f, 0f);
    kf1 = Keyframe.ofFloat(1f, 1f);
    fade = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
    kf0 = Keyframe.ofFloat(0f, -70f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    rotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1);
    mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radius, fade, rotation).setDuration(300);
    mReappearAnimator.addUpdateListener(mInvalidateUpdateListener);
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

Example 8 with PropertyValuesHolder

use of com.nineoldandroids.animation.PropertyValuesHolder in project datetimepicker by flavienlaurent.

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(com.nineoldandroids.animation.Keyframe) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 9 with PropertyValuesHolder

use of com.nineoldandroids.animation.PropertyValuesHolder in project SimplifyReader by chentao0707.

the class SmoothImageView method startTransform.

private void startTransform(final int state) {
    if (mTransfrom == null) {
        return;
    }
    ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setDuration(300);
    valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    if (state == STATE_TRANSFORM_IN) {
        PropertyValuesHolder scaleHolder = PropertyValuesHolder.ofFloat("scale", mTransfrom.startScale, mTransfrom.endScale);
        PropertyValuesHolder leftHolder = PropertyValuesHolder.ofFloat("left", mTransfrom.startRect.left, mTransfrom.endRect.left);
        PropertyValuesHolder topHolder = PropertyValuesHolder.ofFloat("top", mTransfrom.startRect.top, mTransfrom.endRect.top);
        PropertyValuesHolder widthHolder = PropertyValuesHolder.ofFloat("width", mTransfrom.startRect.width, mTransfrom.endRect.width);
        PropertyValuesHolder heightHolder = PropertyValuesHolder.ofFloat("height", mTransfrom.startRect.height, mTransfrom.endRect.height);
        PropertyValuesHolder alphaHolder = PropertyValuesHolder.ofInt("alpha", 0, 255);
        valueAnimator.setValues(scaleHolder, leftHolder, topHolder, widthHolder, heightHolder, alphaHolder);
    } else {
        PropertyValuesHolder scaleHolder = PropertyValuesHolder.ofFloat("scale", mTransfrom.endScale, mTransfrom.startScale);
        PropertyValuesHolder leftHolder = PropertyValuesHolder.ofFloat("left", mTransfrom.endRect.left, mTransfrom.startRect.left);
        PropertyValuesHolder topHolder = PropertyValuesHolder.ofFloat("top", mTransfrom.endRect.top, mTransfrom.startRect.top);
        PropertyValuesHolder widthHolder = PropertyValuesHolder.ofFloat("width", mTransfrom.endRect.width, mTransfrom.startRect.width);
        PropertyValuesHolder heightHolder = PropertyValuesHolder.ofFloat("height", mTransfrom.endRect.height, mTransfrom.startRect.height);
        PropertyValuesHolder alphaHolder = PropertyValuesHolder.ofInt("alpha", 255, 0);
        valueAnimator.setValues(scaleHolder, leftHolder, topHolder, widthHolder, heightHolder, alphaHolder);
    }
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public synchronized void onAnimationUpdate(ValueAnimator animation) {
            mTransfrom.scale = (Float) animation.getAnimatedValue("scale");
            mTransfrom.rect.left = (Float) animation.getAnimatedValue("left");
            mTransfrom.rect.top = (Float) animation.getAnimatedValue("top");
            mTransfrom.rect.width = (Float) animation.getAnimatedValue("width");
            mTransfrom.rect.height = (Float) animation.getAnimatedValue("height");
            mBgAlpha = (Integer) animation.getAnimatedValue("alpha");
            invalidate();
            ((Activity) getContext()).getWindow().getDecorView().invalidate();
        }
    });
    valueAnimator.addListener(new ValueAnimator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // TODO 这个可以根据实际需求来修改
            if (state == STATE_TRANSFORM_IN) {
                mState = STATE_NORMAL;
            }
            if (mTransformListener != null) {
                mTransformListener.onTransformComplete(state);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    valueAnimator.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 10 with PropertyValuesHolder

use of com.nineoldandroids.animation.PropertyValuesHolder in project android-betterpickers by code-troopers.

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(AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusReappear, fadeIn).setDuration(totalDuration);
    reappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    return reappearAnimator;
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Aggregations

PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)15 Keyframe (com.nineoldandroids.animation.Keyframe)12 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)11 Paint (android.graphics.Paint)6 Animator (com.nineoldandroids.animation.Animator)2 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)2 SurfaceView (android.view.SurfaceView)1 View (android.view.View)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 ImageView (android.widget.ImageView)1 RadioGroup (android.widget.RadioGroup)1 RelativeLayout (android.widget.RelativeLayout)1 InjectView (butterknife.InjectView)1 CommonImagePickerListActivity (com.github.obsessive.simplifyreader.ui.activity.picker.CommonImagePickerListActivity)1 BeepManager (com.github.obsessive.simplifyreader.ui.activity.qrcode.utils.BeepManager)1 InactivityTimer (com.github.obsessive.simplifyreader.ui.activity.qrcode.utils.InactivityTimer)1