Search in sources :

Example 56 with ObjectAnimator

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

the class RadialPickerLayout method setCurrentItemShowing.

/**
     * Set either minutes or hours as showing.
     *
     * @param animate True to animate the transition, false to show with no animation.
     */
public void setCurrentItemShowing(int index, boolean animate) {
    if (index != HOUR_INDEX && index != MINUTE_INDEX) {
        Log.e(TAG, "TimePicker does not support view at index " + index);
        return;
    }
    int lastIndex = getCurrentItemShowing();
    mCurrentItemShowing = index;
    if (animate && (index != lastIndex)) {
        ObjectAnimator[] anims = new ObjectAnimator[4];
        if (index == MINUTE_INDEX) {
            anims[0] = mHourRadialTextsView.getDisappearAnimator();
            anims[1] = mHourRadialSelectorView.getDisappearAnimator();
            anims[2] = mMinuteRadialTextsView.getReappearAnimator();
            anims[3] = mMinuteRadialSelectorView.getReappearAnimator();
        } else if (index == HOUR_INDEX) {
            anims[0] = mHourRadialTextsView.getReappearAnimator();
            anims[1] = mHourRadialSelectorView.getReappearAnimator();
            anims[2] = mMinuteRadialTextsView.getDisappearAnimator();
            anims[3] = mMinuteRadialSelectorView.getDisappearAnimator();
        }
        if (mTransition != null && mTransition.isRunning()) {
            mTransition.end();
        }
        mTransition = new AnimatorSet();
        mTransition.playTogether(anims);
        mTransition.start();
    } else {
        int hourAlpha = (index == HOUR_INDEX) ? 255 : 0;
        int minuteAlpha = (index == MINUTE_INDEX) ? 255 : 0;
        ViewHelper.setAlpha(mHourRadialTextsView, hourAlpha);
        ViewHelper.setAlpha(mHourRadialSelectorView, hourAlpha);
        ViewHelper.setAlpha(mMinuteRadialTextsView, minuteAlpha);
        ViewHelper.setAlpha(mMinuteRadialSelectorView, minuteAlpha);
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) SuppressLint(android.annotation.SuppressLint)

Example 57 with ObjectAnimator

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

the class Utils 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("scaleX", k0, k1, k2, k3);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
    ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(labelToAnimate) : 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 58 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project PaymentKit-Droid by brendanw.

the class AnimUtils method getShakeAnimation.

/**
     * @param shouldResetTextColor if true make sure you end the previous animation before starting this one.
     */
public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) {
    final int textColor = textView.getCurrentTextColor();
    textView.setTextColor(Color.RED);
    ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16);
    shakeAnim.setDuration(SHAKE_DURATION);
    shakeAnim.setInterpolator(new CycleInterpolator(2.0f));
    shakeAnim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator anim) {
            if (shouldResetTextColor) {
                textView.setTextColor(textColor);
            }
        }
    });
    return shakeAnim;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) CycleInterpolator(android.view.animation.CycleInterpolator)

Example 59 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Carbon by ZieIony.

the class RippleForeground method createSoftwareExit.

@Override
protected Animator createSoftwareExit() {
    final int radiusDuration;
    final int originDuration;
    final int opacityDuration;
    if (mIsBounded) {
        computeBoundedTargetValues();
        radiusDuration = BOUNDED_RADIUS_EXIT_DURATION;
        originDuration = BOUNDED_ORIGIN_EXIT_DURATION;
        opacityDuration = BOUNDED_OPACITY_EXIT_DURATION;
    } else {
        radiusDuration = getRadiusExitDuration();
        originDuration = radiusDuration;
        opacityDuration = getOpacityExitDuration();
    }
    final ObjectAnimator tweenRadius = ObjectAnimator.ofFloat(this, TWEEN_RADIUS, 1);
    AnimatorsCompat.setAutoCancel(tweenRadius);
    //tweenRadius.setAutoCancel(true);
    tweenRadius.setDuration(radiusDuration);
    tweenRadius.setInterpolator(DECELERATE_INTERPOLATOR);
    final ObjectAnimator tweenOrigin = ObjectAnimator.ofFloat(this, TWEEN_ORIGIN, 1);
    AnimatorsCompat.setAutoCancel(tweenOrigin);
    //tweenOrigin.setAutoCancel(true);
    tweenOrigin.setDuration(originDuration);
    tweenOrigin.setInterpolator(DECELERATE_INTERPOLATOR);
    final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, OPACITY, 0);
    AnimatorsCompat.setAutoCancel(opacity);
    //opacity.setAutoCancel(true);
    opacity.setDuration(opacityDuration);
    opacity.setInterpolator(LINEAR_INTERPOLATOR);
    final AnimatorSet set = new AnimatorSet();
    set.play(tweenOrigin).with(tweenRadius).with(opacity);
    set.addListener(mAnimationListener);
    return set;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) Paint(android.graphics.Paint)

Example 60 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Carbon by ZieIony.

the class AnimatorsCompat method hasSameTargetAndProperties.

private static boolean hasSameTargetAndProperties(ObjectAnimator self, @Nullable Animator anim) {
    if (anim instanceof ObjectAnimator) {
        PropertyValuesHolder[] theirValues = ((ObjectAnimator) anim).getValues();
        PropertyValuesHolder[] selfValues = self.getValues();
        if (((ObjectAnimator) anim).getTarget() == self.getTarget() && selfValues.length == theirValues.length) {
            final int length = selfValues.length;
            for (int i = 0; i < length; ++i) {
                PropertyValuesHolder pvhMine = selfValues[i];
                PropertyValuesHolder pvhTheirs = theirValues[i];
                if (pvhMine.getPropertyName() == null || !pvhMine.getPropertyName().equals(pvhTheirs.getPropertyName())) {
                    return false;
                }
            }
            return true;
        }
    }
    return false;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

Aggregations

ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)81 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)27 Animator (com.nineoldandroids.animation.Animator)20 View (android.view.View)11 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)10 Keyframe (com.nineoldandroids.animation.Keyframe)9 Paint (android.graphics.Paint)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 TextView (android.widget.TextView)5 AdapterView (android.widget.AdapterView)4 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)3 SupportAnimator (io.codetail.animation.SupportAnimator)3