Search in sources :

Example 46 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project CoCoin by Nightonke.

the class RiseNumberTextView method runFloat.

private void runFloat() {
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(fromNumber, number);
    valueAnimator.setDuration(duration);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            setText(fnum.format(Float.parseFloat(valueAnimator.getAnimatedValue().toString())));
            if (valueAnimator.getAnimatedFraction() >= 1) {
                mPlayingState = STOPPED;
                if (mEndListener != null)
                    mEndListener.onEndFinish();
            }
        }
    });
    valueAnimator.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 47 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project CoCoin by Nightonke.

the class RiseNumberTextView method runInt.

private void runInt() {
    ValueAnimator valueAnimator = ValueAnimator.ofInt((int) fromNumber, (int) number);
    valueAnimator.setDuration(duration);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            setText(valueAnimator.getAnimatedValue().toString());
            if (valueAnimator.getAnimatedFraction() >= 1) {
                mPlayingState = STOPPED;
                if (mEndListener != null)
                    mEndListener.onEndFinish();
            }
        }
    });
    valueAnimator.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 48 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator 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 49 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project SunDay by iQuick.

the class SwipeListViewTouchListener method performDismiss.

/**
     * Perform dismiss action
     *
     * @param dismissView     View
     * @param dismissPosition Position of list
     */
protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) {
    final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
    final int originalHeight = dismissView.getHeight();
    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime);
    if (doPendingDismiss) {
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                --dismissAnimationRefCount;
                if (dismissAnimationRefCount == 0) {
                    removePendingDismisses(originalHeight);
                }
            }
        });
    }
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            dismissView.setLayoutParams(lp);
        }
    });
    pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
    animator.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 50 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project AndroidSweetSheet by zzz40500.

the class CircleRevealHelper method circularReveal.

public void circularReveal(int centerX, int centerY, float startRadius, float endRadius, long duration, Interpolator interpolator) {
    mAnchorX = centerX;
    mAnchorY = centerY;
    if (mView.getParent() == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= 21) {
        Animator animator = ViewAnimationUtils.createCircularReveal(mView, mAnchorX, mAnchorY, startRadius, endRadius);
        animator.setInterpolator(interpolator);
        animator.setDuration(duration);
        animator.start();
    } else {
        ValueAnimator valueAnimator = ValueAnimator.ofFloat(startRadius, endRadius);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mRadius = (float) animation.getAnimatedValue();
                mView.invalidate();
            }
        });
        valueAnimator.setInterpolator(interpolator);
        valueAnimator.addListener(new SimpleAnimationListener() {

            @Override
            public void onAnimationStart(com.nineoldandroids.animation.Animator animation) {
                isCircularReveal = true;
            }

            @Override
            public void onAnimationEnd(com.nineoldandroids.animation.Animator animation) {
                isCircularReveal = false;
            }

            @Override
            public void onAnimationCancel(com.nineoldandroids.animation.Animator animation) {
                isCircularReveal = false;
            }
        });
        valueAnimator.setDuration(duration);
        valueAnimator.start();
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(android.animation.Animator) SimpleAnimationListener(com.mingle.SimpleAnimationListener) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Aggregations

ValueAnimator (com.nineoldandroids.animation.ValueAnimator)105 Animator (com.nineoldandroids.animation.Animator)55 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)46 StateAnimator (carbon.animation.StateAnimator)30 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)19 View (android.view.View)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)15 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 Paint (android.graphics.Paint)7 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 RecyclerView (android.support.v7.widget.RecyclerView)4 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 FrameLayout (android.widget.FrameLayout)4 ImageView (android.widget.ImageView)4 ArrayList (java.util.ArrayList)4 MotionEvent (android.view.MotionEvent)3 TouchInterceptionFrameLayout (com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout)3 AnimatorUpdateListener (com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener)3