Search in sources :

Example 26 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project AdvancedMaterialDrawer by madcyph3r.

the class MaterialRippleLayoutNineOld method startRipple.

private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled)
        return;
    float endRadius = getEndRadius();
    cancelAnimations();
    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });
    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);
    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 27 with ObjectAnimator

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

the class DatePickerDialog method setCurrentView.

private void setCurrentView(int currentView, boolean forceRefresh) {
    long timeInMillis = mCalendar.getTimeInMillis();
    switch(currentView) {
        case MONTH_AND_DAY_VIEW:
            ObjectAnimator monthDayAnim = Utils.getPulseAnimator(mMonthAndDayView, 0.9F, 1.05F);
            if (mDelayAnimation) {
                monthDayAnim.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }
            mDayPickerView.onDateChanged();
            if (mCurrentView != currentView || forceRefresh) {
                mMonthAndDayView.setSelected(true);
                mYearView.setSelected(false);
                mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW);
                mCurrentView = currentView;
            }
            monthDayAnim.start();
            String monthDayDesc = DateUtils.formatDateTime(getActivity(), timeInMillis, DateUtils.FORMAT_SHOW_DATE);
            mAnimator.setContentDescription(mDayPickerDescription + ": " + monthDayDesc);
            Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay);
            break;
        case YEAR_VIEW:
            ObjectAnimator yearAnim = Utils.getPulseAnimator(mYearView, 0.85F, 1.1F);
            if (mDelayAnimation) {
                yearAnim.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }
            mYearPickerView.onDateChanged();
            if (mCurrentView != currentView || forceRefresh) {
                mMonthAndDayView.setSelected(false);
                mYearView.setSelected(true);
                mAnimator.setDisplayedChild(YEAR_VIEW);
                mCurrentView = currentView;
            }
            yearAnim.start();
            String dayDesc = YEAR_FORMAT.format(timeInMillis);
            mAnimator.setContentDescription(mYearPickerDescription + ": " + dayDesc);
            Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear);
            break;
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 28 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project material-sheet-fab by gowong.

the class ViewAnimationUtils method createCircularReveal.

/**
     * Returns an Animator which can animate a clipping circle.
     * <p>
     * Any shadow cast by the View will respect the circular clip from this animator.
     * <p>
     * Only a single non-rectangular clip can be applied on a View at any time.
     * Views clipped by a circular reveal animation take priority over
     * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}.
     * <p>
     * Note that the animation returned here is a one-shot animation. It cannot
     * be re-used, and once started it cannot be paused or resumed.
     *
     * @param view The View will be clipped to the animating circle.
     * @param centerX The x coordinate of the center of the animating circle.
     * @param centerY The y coordinate of the center of the animating circle.
     * @param startRadius The starting radius of the animating circle.
     * @param endRadius The ending radius of the animating circle.
     */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) {
    if (!(view.getParent() instanceof RevealAnimator)) {
        throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout.");
    }
    RevealAnimator revealLayout = (RevealAnimator) view.getParent();
    revealLayout.attachRevealInfo(new RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view)));
    if (LOLLIPOP_PLUS) {
        return new SupportAnimatorLollipop(android.view.ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout);
    }
    ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, startRadius, endRadius);
    reveal.addListener(getRevealFinishListener(revealLayout));
    return new SupportAnimatorPreL(reveal, revealLayout);
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) WeakReference(java.lang.ref.WeakReference) RevealInfo(io.codetail.animation.RevealAnimator.RevealInfo) TargetApi(android.annotation.TargetApi)

Example 29 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project PhotoNoter by yydcdut.

the class AnimationTopLayout method doAnimation.

public void doAnimation() {
    ObjectAnimator downAnimation = ObjectAnimator.ofFloat(mChildView, "Y", 0f, getResources().getDimension(R.dimen.dimen_48dip));
    downAnimation.setDuration(ANIMATION_TIME / 2);
    downAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (mOnAnimationHalfFinishListener != null) {
                mOnAnimationHalfFinishListener.onHalf(mChildView);
            }
        }
    });
    ObjectAnimator upAnimation = ObjectAnimator.ofFloat(mChildView, "Y", -getResources().getDimension(R.dimen.dimen_48dip), 0f);
    upAnimation.setDuration(ANIMATION_TIME / 2);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(downAnimation, upAnimation);
    animatorSet.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 30 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Rashr by DsLNeXuS.

the class CardStack method getOnLongClickListener.

private OnLongClickListener getOnLongClickListener(final CardStack cardStack, final RelativeLayout container, final int index) {
    return new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // init views array
            View[] views = new View[container.getChildCount()];
            for (int i = 0; i < views.length; i++) {
                views[i] = container.getChildAt(i);
            }
            int last = views.length - 1;
            if (index != last) {
                if (index == 0) {
                    onClickFirstCard(cardStack, container, index, views);
                } else if (index < last) {
                    onClickOtherCard(cardStack, container, index, views, last);
                }
            }
            return false;
        }

        public void onClickFirstCard(final CardStack cardStack, final RelativeLayout frameLayout, final int index, View[] views) {
            // run through all the cards
            for (int i = 0; i < views.length; i++) {
                ObjectAnimator anim = null;
                if (i == 0) {
                    // the first goes all the way down
                    float downFactor = 0;
                    if (views.length > 2) {
                        downFactor = convertDpToPixel((_45F) * (views.length - 1) - 1);
                    } else {
                        downFactor = convertDpToPixel(_45F);
                    }
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, downFactor);
                    anim.addListener(getAnimationListener(cardStack, frameLayout, index, views[index]));
                } else if (i == 1) {
                    // the second goes up just a bit
                    float upFactor = convertDpToPixel(-17f);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                } else {
                    // the rest go up by one card
                    float upFactor = convertDpToPixel(-1 * _45F);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                }
                if (anim != null)
                    anim.start();
            }
        }

        public void onClickOtherCard(final CardStack cardStack, final RelativeLayout frameLayout, final int index, View[] views, int last) {
            // if clicked card is in middle
            for (int i = index; i <= last; i++) {
                // run through the cards from the clicked position
                // and on until the end
                ObjectAnimator anim = null;
                if (i == index) {
                    // the selected card goes all the way down
                    float downFactor = convertDpToPixel(_45F * (last - i) + _12F);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, downFactor);
                    anim.addListener(getAnimationListener(cardStack, frameLayout, index, views[index]));
                } else {
                    // the rest go up by one
                    float upFactor = convertDpToPixel(_45F * -1);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                }
                if (anim != null)
                    anim.start();
            }
        }
    };
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) OnLongClickListener(android.view.View.OnLongClickListener) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) View(android.view.View)

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