Search in sources :

Example 1 with PropertyValuesHolder

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

the class RadialSelectorView method getDisappearAnimator.

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

Example 2 with PropertyValuesHolder

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

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(AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : 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(AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : 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 3 with PropertyValuesHolder

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

the class CaptureActivity method initViewsAndEvents.

@Override
protected void initViewsAndEvents() {
    hasSurface = false;
    mInactivityTimer = new InactivityTimer(this);
    mBeepManager = new BeepManager(this);
    initCropViewAnimator();
    capturePictureBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            readyGoForResult(CommonImagePickerListActivity.class, IMAGE_PICKER_REQUEST_CODE);
        }
    });
    captureLightBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isLightOn) {
                cameraManager.setTorch(false);
                captureLightBtn.setSelected(false);
            } else {
                cameraManager.setTorch(true);
                captureLightBtn.setSelected(true);
            }
            isLightOn = !isLightOn;
        }
    });
    captureModeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.capture_mode_barcode) {
                PropertyValuesHolder qr2barWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mBarcodeCropWidth / mQrcodeCropWidth);
                PropertyValuesHolder qr2barHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mBarcodeCropHeight / mQrcodeCropHeight);
                ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(qr2barWidthVH, qr2barHeightVH);
                valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        Float fractionW = (Float) animation.getAnimatedValue("width");
                        Float fractionH = (Float) animation.getAnimatedValue("height");
                        RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
                        parentLayoutParams.width = (int) (mQrcodeCropWidth * fractionW);
                        parentLayoutParams.height = (int) (mQrcodeCropHeight * fractionH);
                        captureCropView.setLayoutParams(parentLayoutParams);
                    }
                });
                valueAnimator.addListener(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        initCrop();
                        setDataMode(DecodeUtils.DECODE_DATA_MODE_BARCODE);
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }
                });
                valueAnimator.start();
            } else if (checkedId == R.id.capture_mode_qrcode) {
                PropertyValuesHolder bar2qrWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mQrcodeCropWidth / mBarcodeCropWidth);
                PropertyValuesHolder bar2qrHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mQrcodeCropHeight / mBarcodeCropHeight);
                ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(bar2qrWidthVH, bar2qrHeightVH);
                valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        Float fractionW = (Float) animation.getAnimatedValue("width");
                        Float fractionH = (Float) animation.getAnimatedValue("height");
                        RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
                        parentLayoutParams.width = (int) (mBarcodeCropWidth * fractionW);
                        parentLayoutParams.height = (int) (mBarcodeCropHeight * fractionH);
                        captureCropView.setLayoutParams(parentLayoutParams);
                    }
                });
                valueAnimator.addListener(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        initCrop();
                        setDataMode(DecodeUtils.DECODE_DATA_MODE_QRCODE);
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }
                });
                valueAnimator.start();
            }
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) InactivityTimer(com.github.obsessive.simplifyreader.ui.activity.qrcode.utils.InactivityTimer) BeepManager(com.github.obsessive.simplifyreader.ui.activity.qrcode.utils.BeepManager) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) CommonImagePickerListActivity(com.github.obsessive.simplifyreader.ui.activity.picker.CommonImagePickerListActivity) RelativeLayout(android.widget.RelativeLayout) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

Example 4 with PropertyValuesHolder

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

the class DateTimePickerUtils method getPulseAnimator.

/**
     * 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(sPropertyScaleX, k0, k1, k2, k3);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe(sPropertyScaleY, k0, k1, k2, k3);
    ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
    pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
    return pulseAnimator;
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

Example 5 with PropertyValuesHolder

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

the class RadialSelectorView method getDisappearAnimator.

public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }
    Keyframe kf0, kf1;
    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fade = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, fade).setDuration(300);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    return disappearAnimator;
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

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