Example usage for android.animation AnimatorSet addListener

List of usage examples for android.animation AnimatorSet addListener

Introduction

In this page you can find the example usage for android.animation AnimatorSet addListener.

Prototype

public void addListener(AnimatorListener listener) 

Source Link

Document

Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.

Usage

From source file:org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView.java

/**
 * Animates the card being swiped to the right as if the user had dismissed it. Any changes to
 * the animation here should be reflected also in
 * {@link #updateViewStateForDismiss(float, ViewHolder)} and reset in
 * {@link CardViewHolder#onBindViewHolder()}.
 * @param suggestion The item to be dismissed.
 *//*  ww w . j  a v a2  s.c om*/
public void dismissItemWithAnimation(SnippetArticle suggestion) {
    // We need to recompute the position, as it might have changed.
    final int position = getNewTabPageAdapter().getSuggestionPosition(suggestion);
    if (position == RecyclerView.NO_POSITION) {
        // The item does not exist anymore, so ignore.
        return;
    }

    final View itemView = mLayoutManager.findViewByPosition(position);
    if (itemView == null) {
        // The view is not visible anymore, skip the animation.
        getNewTabPageAdapter().dismissItem(position);
        return;
    }

    final ViewHolder viewHolder = getChildViewHolder(itemView);
    if (!((NewTabPageViewHolder) viewHolder).isDismissable()) {
        // The item is not dismissable (anymore), so ignore.
        return;
    }

    AnimatorSet animation = new AnimatorSet();
    animation.playTogether(ObjectAnimator.ofFloat(itemView, View.ALPHA, 0f),
            ObjectAnimator.ofFloat(itemView, View.TRANSLATION_X, (float) itemView.getWidth()));

    animation.setDuration(DISMISS_ANIMATION_TIME_MS);
    animation.setInterpolator(DISMISS_INTERPOLATOR);
    animation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            NewTabPageRecyclerView.this.onItemDismissStarted(viewHolder);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            getNewTabPageAdapter().dismissItem(position);
            NewTabPageRecyclerView.this.onItemDismissFinished(viewHolder);
        }
    });
    animation.start();
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setOrAnimateIconTo(final ImageView imageView, final int imageResId, boolean animate) {
    if (UIUtils.hasICS() && imageView.getTag() != null) {
        if (imageView.getTag() instanceof Animator) {
            Animator anim = (Animator) imageView.getTag();
            anim.end();/*from  ww  w  .  jav  a 2 s .  c  om*/
            imageView.setAlpha(1f);
        }
    }

    animate = animate && UIUtils.hasICS();
    if (animate) {
        int duration = getResources().getInteger(android.R.integer.config_shortAnimTime);

        Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f);
        outAnimator.setDuration(duration / 2);
        outAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setImageResource(imageResId);
            }
        });

        AnimatorSet inAnimator = new AnimatorSet();
        outAnimator.setDuration(duration);
        inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f),
                ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f),
                ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f));

        AnimatorSet set = new AnimatorSet();
        set.playSequentially(outAnimator, inAnimator);
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setTag(null);
            }
        });
        imageView.setTag(set);
        set.start();
    } else {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                imageView.setImageResource(imageResId);
            }
        });
    }
}

From source file:com.bachhuberdesign.deckbuildergwent.util.FabTransform.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, final TransitionValues startValues,
        final TransitionValues endValues) {
    if (startValues == null || endValues == null)
        return null;

    final Rect startBounds = (Rect) startValues.values.get(PROP_BOUNDS);
    final Rect endBounds = (Rect) endValues.values.get(PROP_BOUNDS);

    final boolean fromFab = endBounds.width() > startBounds.width();
    final View view = endValues.view;
    final Rect dialogBounds = fromFab ? endBounds : startBounds;
    final Interpolator fastOutSlowInInterpolator = AnimUtils.getFastOutSlowInInterpolator();
    final long duration = getDuration();
    final long halfDuration = duration / 2;
    final long twoThirdsDuration = duration * 2 / 3;

    if (!fromFab) {
        // Force measure / layout the dialog back to it's original bounds
        view.measure(makeMeasureSpec(startBounds.width(), View.MeasureSpec.EXACTLY),
                makeMeasureSpec(startBounds.height(), View.MeasureSpec.EXACTLY));
        view.layout(startBounds.left, startBounds.top, startBounds.right, startBounds.bottom);
    }/*from w w  w .  j ava 2  s  .  c  om*/

    final int translationX = startBounds.centerX() - endBounds.centerX();
    final int translationY = startBounds.centerY() - endBounds.centerY();
    if (fromFab) {
        view.setTranslationX(translationX);
        view.setTranslationY(translationY);
    }

    // Add a color overlay to fake appearance of the FAB
    final ColorDrawable fabColor = new ColorDrawable(color);
    fabColor.setBounds(0, 0, dialogBounds.width(), dialogBounds.height());
    if (!fromFab)
        fabColor.setAlpha(0);
    view.getOverlay().add(fabColor);

    // Add an icon overlay again to fake the appearance of the FAB
    final Drawable fabIcon = ContextCompat.getDrawable(sceneRoot.getContext(), icon).mutate();
    final int iconLeft = (dialogBounds.width() - fabIcon.getIntrinsicWidth()) / 2;
    final int iconTop = (dialogBounds.height() - fabIcon.getIntrinsicHeight()) / 2;
    fabIcon.setBounds(iconLeft, iconTop, iconLeft + fabIcon.getIntrinsicWidth(),
            iconTop + fabIcon.getIntrinsicHeight());
    if (!fromFab)
        fabIcon.setAlpha(0);
    view.getOverlay().add(fabIcon);

    // Since the view that's being transition to always seems to be on the top (z-order), we have
    // to make a copy of the "from" view and put it in the "to" view's overlay, then fade it out.
    // There has to be another way to do this, right?
    Drawable dialogView = null;
    if (!fromFab) {
        startValues.view.setDrawingCacheEnabled(true);
        startValues.view.buildDrawingCache();
        Bitmap viewBitmap = startValues.view.getDrawingCache();
        dialogView = new BitmapDrawable(view.getResources(), viewBitmap);
        dialogView.setBounds(0, 0, dialogBounds.width(), dialogBounds.height());
        view.getOverlay().add(dialogView);
    }

    // Circular clip from/to the FAB size
    final Animator circularReveal;
    if (fromFab) {
        circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2,
                view.getHeight() / 2, startBounds.width() / 2,
                (float) Math.hypot(endBounds.width() / 2, endBounds.height() / 2));
        circularReveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator());
    } else {
        circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2,
                view.getHeight() / 2, (float) Math.hypot(startBounds.width() / 2, startBounds.height() / 2),
                endBounds.width() / 2);
        circularReveal.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator());

        // Persist the end clip i.e. stay at FAB size after the reveal has run
        circularReveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                final ViewOutlineProvider fabOutlineProvider = view.getOutlineProvider();

                view.setOutlineProvider(new ViewOutlineProvider() {
                    boolean hasRun = false;

                    @Override
                    public void getOutline(final View view, Outline outline) {
                        final int left = (view.getWidth() - endBounds.width()) / 2;
                        final int top = (view.getHeight() - endBounds.height()) / 2;

                        outline.setOval(left, top, left + endBounds.width(), top + endBounds.height());

                        if (!hasRun) {
                            hasRun = true;
                            view.setClipToOutline(true);

                            // We have to remove this as soon as it's laid out so we can get the shadow back
                            view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
                                @Override
                                public boolean onPreDraw() {
                                    if (view.getWidth() == endBounds.width()
                                            && view.getHeight() == endBounds.height()) {
                                        view.setOutlineProvider(fabOutlineProvider);
                                        view.setClipToOutline(false);
                                        view.getViewTreeObserver().removeOnPreDrawListener(this);
                                        return true;
                                    }

                                    return true;
                                }
                            });
                        }
                    }
                });
            }
        });
    }
    circularReveal.setDuration(duration);

    // Translate to end position along an arc
    final Animator translate = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, View.TRANSLATION_Y,
            fromFab ? getPathMotion().getPath(translationX, translationY, 0, 0)
                    : getPathMotion().getPath(0, 0, -translationX, -translationY));
    translate.setDuration(duration);
    translate.setInterpolator(fastOutSlowInInterpolator);

    // Fade contents of non-FAB view in/out
    List<Animator> fadeContents = null;
    if (view instanceof ViewGroup) {
        final ViewGroup vg = ((ViewGroup) view);
        fadeContents = new ArrayList<>(vg.getChildCount());
        for (int i = vg.getChildCount() - 1; i >= 0; i--) {
            final View child = vg.getChildAt(i);
            final Animator fade = ObjectAnimator.ofFloat(child, View.ALPHA, fromFab ? 1f : 0f);
            if (fromFab) {
                child.setAlpha(0f);
            }
            fade.setDuration(twoThirdsDuration);
            fade.setInterpolator(fastOutSlowInInterpolator);
            fadeContents.add(fade);
        }
    }

    // Fade in/out the fab color & icon overlays
    final Animator colorFade = ObjectAnimator.ofInt(fabColor, "alpha", fromFab ? 0 : 255);
    final Animator iconFade = ObjectAnimator.ofInt(fabIcon, "alpha", fromFab ? 0 : 255);
    if (!fromFab) {
        colorFade.setStartDelay(halfDuration);
        iconFade.setStartDelay(halfDuration);
    }
    colorFade.setDuration(halfDuration);
    iconFade.setDuration(halfDuration);
    colorFade.setInterpolator(fastOutSlowInInterpolator);
    iconFade.setInterpolator(fastOutSlowInInterpolator);

    // Run all animations together
    final AnimatorSet transition = new AnimatorSet();
    transition.playTogether(circularReveal, translate, colorFade, iconFade);
    transition.playTogether(fadeContents);
    if (dialogView != null) {
        final Animator dialogViewFade = ObjectAnimator.ofInt(dialogView, "alpha", 0)
                .setDuration(twoThirdsDuration);
        dialogViewFade.setInterpolator(fastOutSlowInInterpolator);
        transition.playTogether(dialogViewFade);
    }
    transition.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            // Clean up
            view.getOverlay().clear();

            if (!fromFab) {
                view.setTranslationX(0);
                view.setTranslationY(0);
                view.setTranslationZ(0);

                view.measure(makeMeasureSpec(endBounds.width(), View.MeasureSpec.EXACTLY),
                        makeMeasureSpec(endBounds.height(), View.MeasureSpec.EXACTLY));
                view.layout(endBounds.left, endBounds.top, endBounds.right, endBounds.bottom);
            }

        }
    });
    return new AnimUtils.NoPauseAnimator(transition);
}

From source file:eu.davidea.flexibleadapter.FlexibleAnimatorAdapter.java

/**
 * Animates the view based on the custom animator list built with {@link #getAnimators(View, int, boolean)}.
 *//* ww w.  j a  va  2  s  . com*/
public final void animateView(final View itemView, int position, boolean isSelected) {
    //FIXME: first completed visible item on rotation gets high delay

    //      if (DEBUG)
    //         Log.v(TAG, "shouldAnimate=" + shouldAnimate
    //               + " isFastScroll=" + isFastScroll
    //               + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified()
    //               + " isReverseEnabled=" + isReverseEnabled
    //               + (!isReverseEnabled ? " Pos>AniPos=" + (position > mLastAnimatedPosition) : "")
    //         );

    if (shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified()
            && (isReverseEnabled || (!isReverseEnabled && position > mLastAnimatedPosition))) {

        //Cancel animation is necessary when fling
        cancelExistingAnimation(itemView);

        //Retrieve user animators
        List<Animator> animators = getAnimators(itemView, position, isSelected);

        //Add Alpha animator if not yet
        ViewCompat.setAlpha(itemView, 0);
        if (!animatorsUsed.contains(AnimatorEnum.ALPHA))
            addAlphaAnimator(animators, itemView, 0f);
        //Clear animators since the new item might have different animations
        animatorsUsed.clear();

        //Execute the animations all together
        AnimatorSet set = new AnimatorSet();
        set.playTogether(animators);
        //TODO: Animate with Solution 1 or 2?
        //set.setStartDelay(calculateAnimationDelay1(position));
        set.setStartDelay(calculateAnimationDelay2(position));
        set.setInterpolator(mInterpolator);
        set.setDuration(mDuration);
        set.addListener(new HelperAnimatorListener(itemView.hashCode()));
        set.start();
        if (DEBUG)
            Log.v(TAG, "Started Animation on position " + position + " animatorsUsed=" + animatorsUsed);
        mAnimators.put(itemView.hashCode(), set);
    }

    if (mAnimatorNotifierObserver.isPositionNotified())
        mAnimatorNotifierObserver.clearNotified();

    mLastAnimatedPosition = position;
}

From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private synchronized void startFloatingAnimation() {
    final String property = mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM ? "translationY"
            : "translationX";

    final ObjectAnimator anim1 = ObjectAnimator.ofFloat(mContentLayout, property, -mAnimationPadding,
            mAnimationPadding);/*from w  w w  . jav  a  2  s.  co  m*/
    anim1.setDuration(mAnimationDuration);
    anim1.setInterpolator(new AccelerateDecelerateInterpolator());

    final ObjectAnimator anim2 = ObjectAnimator.ofFloat(mContentLayout, property, mAnimationPadding,
            -mAnimationPadding);
    anim2.setDuration(mAnimationDuration);
    anim2.setInterpolator(new AccelerateDecelerateInterpolator());

    AnimatorSet set = new AnimatorSet();
    set.playSequentially(anim1, anim2);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (isShowing()) {
                animation.start();
            }
        }
    });
    mAnimator = set;
    mAnimator.start();
}

From source file:com.sbgapps.scoreit.ui.ScoreItActivity.java

public void setActionButtonProperties(boolean animate) {
    if (animate) {
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(mActionButton, "scaleX", 0f);
        ObjectAnimator scaleY = ObjectAnimator.ofFloat(mActionButton, "scaleY", 0f);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.addListener(new Animator.AnimatorListener() {
            @Override/*  w w w. j ava  2  s. co m*/
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                setActionButtonColor();
                setActionButtonPosition();
                ObjectAnimator scaleX = ObjectAnimator.ofFloat(mActionButton, "scaleX", 1f);
                ObjectAnimator scaleY = ObjectAnimator.ofFloat(mActionButton, "scaleY", 1f);
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.play(scaleX).with(scaleY);
                animatorSet.start();
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
        animatorSet.play(scaleX).with(scaleY);
        animatorSet.start();
    } else {
        setActionButtonPosition();
    }
}

From source file:eu.davidea.flexibleadapter.AnimatorAdapter.java

/**
 * Animates the view based on the custom animator list built with {@link #getAnimators(View, int, boolean)}.
 *
 * @since 5.0.0-b1//from  w  w w  . j a v a2  s. c om
 * @deprecated New system in place. Implement {@link FlexibleViewHolder#scrollAnimators(List, int, boolean)}
 * and add new animator(s) to the list of {@code animators}.
 */
@Deprecated
public final void animateView(final View itemView, int position) {
    //      if (DEBUG)
    //         Log.v(TAG, "shouldAnimate=" + shouldAnimate
    //               + " isFastScroll=" + isFastScroll
    //               + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified()
    //               + " isReverseEnabled=" + isReverseEnabled
    //               + " mLastAnimatedPosition=" + mLastAnimatedPosition
    //               + (!isReverseEnabled ? " Pos>AniPos=" + (position > mLastAnimatedPosition) : "")
    //         );

    if (shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified() && (isReverseEnabled
            || position > mLastAnimatedPosition || (position == 0 && mRecyclerView.getChildCount() == 0))) {

        //Cancel animation is necessary when fling
        cancelExistingAnimation(itemView.hashCode());

        //Retrieve user animators
        List<Animator> animators = getAnimators(itemView, position, position > mLastAnimatedPosition);

        //Add Alpha animator
        ViewCompat.setAlpha(itemView, 0);
        animators.add(ObjectAnimator.ofFloat(itemView, "alpha", 0f, 1f));
        if (DEBUG)
            Log.d(TAG, "Started Deprecated Animation on position " + position);

        //Execute the animations
        AnimatorSet set = new AnimatorSet();
        set.playTogether(animators);
        set.setInterpolator(mInterpolator);
        set.setDuration(mDuration);
        set.addListener(new HelperAnimatorListener(itemView.hashCode()));
        if (mEntryStep) {
            //set.setStartDelay(calculateAnimationDelay1(position));
            set.setStartDelay(calculateAnimationDelay2(position));
        }
        set.start();
        mAnimators.put(itemView.hashCode(), set);

        //Animate only during initial loading?
        if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) {
            shouldAnimate = false;
        }
    }

    mAnimatorNotifierObserver.clearNotified();
    mLastAnimatedPosition = position;
}

From source file:com.android.deskclock.timer.TimerFragment.java

/**
 * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView}
 * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer
 *      should be removed//from w  w  w .  j  a v a 2 s  . c om
 */
private void animateToView(View toView, final Timer timerToRemove) {
    if (mCurrentView == toView) {
        throw new IllegalStateException("toView is already the current view");
    }

    final boolean toTimers = toView == mTimersView;

    // Avoid double-taps by enabling/disabling the set of buttons active on the new view.
    mLeftButton.setEnabled(toTimers);
    mRightButton.setEnabled(toTimers);
    mCancelCreateButton.setEnabled(!toTimers);

    final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0);
    rotateFrom.setDuration(mShortAnimationDuration);
    rotateFrom.setInterpolator(new DecelerateInterpolator());
    rotateFrom.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (timerToRemove != null) {
                DataModel.getDataModel().removeTimer(timerToRemove);
                Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock);
            }

            mCurrentView.setScaleX(1);
            if (toTimers) {
                showTimersView();
            } else {
                showCreateTimerView();
            }
        }
    });

    final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1);
    rotateTo.setDuration(mShortAnimationDuration);
    rotateTo.setInterpolator(new AccelerateInterpolator());

    final float preScale = toTimers ? 0 : 1;
    final float postScale = toTimers ? 1 : 0;
    final Animator fabAnimator = getScaleAnimator(mFab, preScale, postScale);
    final Animator leftButtonAnimator = getScaleAnimator(mLeftButton, preScale, postScale);
    final Animator rightButtonAnimator = getScaleAnimator(mRightButton, preScale, postScale);

    final AnimatorSet buttons = new AnimatorSet();
    buttons.setDuration(toTimers ? mMediumAnimationDuration : mShortAnimationDuration);
    buttons.play(leftButtonAnimator).with(rightButtonAnimator).with(fabAnimator);
    buttons.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mLeftButton.setVisibility(toTimers ? VISIBLE : INVISIBLE);
            mRightButton.setVisibility(toTimers ? VISIBLE : INVISIBLE);

            mFab.setScaleX(1);
            mFab.setScaleY(1);
            mLeftButton.setScaleX(1);
            mLeftButton.setScaleY(1);
            mRightButton.setScaleX(1);
            mRightButton.setScaleY(1);
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(rotateFrom).before(rotateTo).with(buttons);
    animatorSet.start();
}

From source file:eu.davidea.flexibleadapter.AnimatorAdapter.java

protected void animateView(final RecyclerView.ViewHolder holder, final int position) {
    //FIXME: first completed visible item on rotation gets high delay

    //      if (DEBUG)
    //         Log.v(TAG, "shouldAnimate=" + shouldAnimate
    //               + " isFastScroll=" + isFastScroll
    //               + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified()
    //               + " isReverseEnabled=" + isReverseEnabled
    //               + " mLastAnimatedPosition=" + mLastAnimatedPosition
    //               + (!isReverseEnabled ? " Pos>AniPos=" + (position > mLastAnimatedPosition) : "")
    //         );

    if (holder instanceof FlexibleViewHolder && shouldAnimate && !isFastScroll
            && !mAnimatorNotifierObserver.isPositionNotified()
            && (isReverseEnabled || position > mLastAnimatedPosition
                    || (position == 0 && mRecyclerView.getChildCount() == 0))) {

        //Cancel animation is necessary when fling
        int hashCode = holder.itemView.hashCode();
        cancelExistingAnimation(hashCode);

        //User animators
        List<Animator> animators = new ArrayList<>();
        FlexibleViewHolder flexibleViewHolder = (FlexibleViewHolder) holder;
        flexibleViewHolder.scrollAnimators(animators, position, position > mLastAnimatedPosition);

        //Execute the animations together
        AnimatorSet set = new AnimatorSet();
        set.playTogether(animators);/*  w ww  .  j a  v  a  2s  . c  o m*/
        set.setInterpolator(mInterpolator);
        set.setDuration(mDuration);
        set.addListener(new HelperAnimatorListener(hashCode));
        if (mEntryStep) {
            //Stop stepDelay when screen is filled
            set.setStartDelay(calculateAnimationDelay2(position));
        }
        set.start();
        mAnimators.put(hashCode, set);
        if (DEBUG)
            Log.d(TAG, "Started Animation on position " + position);

        //Animate only during initial loading?
        if (onlyEntryAnimation && position >= mMaxChildViews) {
            shouldAnimate = false;
        }
    }

    mAnimatorNotifierObserver.clearNotified();
    mLastAnimatedPosition = position;
}

From source file:com.flexible.flexibleadapter.AnimatorAdapter.java

/**
 * Animates the view based on the custom animator list built with {@link #getAnimators(View, int, boolean)}.
 *
 * @since 5.0.0-b1/*from ww  w .j a v  a2s  .  c  o  m*/
 * @deprecated New system in place. Implement {@link FlexibleViewHolder#scrollAnimators(List, int, boolean)}
 * and add new animator(s) to the list of {@code animators}.
 */
@Deprecated
public final void animateView(final View itemView, int position) {
    //      if (DEBUG)
    //         Log.v(TAG, "shouldAnimate=" + shouldAnimate
    //               + " isFastScroll=" + isFastScroll
    //               + " isNotified=" + mAnimatorNotifierObserver.isPositionNotified()
    //               + " isReverseEnabled=" + isReverseEnabled
    //               + " mLastAnimatedPosition=" + mLastAnimatedPosition
    //               + (!isReverseEnabled ? " Pos>AniPos=" + (position > mLastAnimatedPosition) : "")
    //         );

    if (shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified() && (isReverseEnabled
            || position > mLastAnimatedPosition || (position == 0 && mRecyclerView.getChildCount() == 0))) {

        //Cancel animation is necessary when fling
        cancelExistingAnimation(itemView.hashCode());

        //Retrieve user animators
        List<Animator> animators = getAnimators(itemView, position, position > mLastAnimatedPosition);

        //Add Alpha animator
        ViewCompat.setAlpha(itemView, 0);
        animators.add(ObjectAnimator.ofFloat(itemView, "alpha", 0f, 1f));
        Log.w(TAG, "Started Deprecated Animation on position " + position);

        //Execute the animations
        AnimatorSet set = new AnimatorSet();
        set.playTogether(animators);
        set.setInterpolator(mInterpolator);
        set.setDuration(mDuration);
        set.addListener(new HelperAnimatorListener(itemView.hashCode()));
        if (mEntryStep) {
            set.setStartDelay(calculateAnimationDelay(position));
        }
        set.start();
        mAnimators.put(itemView.hashCode(), set);

        //Animate only during initial loading?
        if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) {
            shouldAnimate = false;
        }
    }

    mAnimatorNotifierObserver.clearNotified();
    mLastAnimatedPosition = position;
}