示例#1
0
        /**
         * Animates given View if necessary.
         *
         * @param position the position of the item the View represents.
         * @param view     the View that should be animated.
         * @param parent   the parent the View is hosted in.
         */
        private void animateViewIfNecessary(int position, View view, ViewGroup parent)
        {
            //assert mViewAnimator != null;

            /* GridView measures the first View which is returned by getView(int, View, ViewGroup), but does not use that View.
             * On KitKat, it does this actually multiple times.
             * Therefore, we animate all these first Views, and reset the last animated position when we suspect GridView is measuring. */
            mGridViewPossiblyMeasuring = mGridViewPossiblyMeasuring && (mGridViewMeasuringPosition == -1 || mGridViewMeasuringPosition == position);

            if (mGridViewPossiblyMeasuring)
            {
                mGridViewMeasuringPosition = position;
                mViewAnimator.setLastAnimatedPosition(-1);
            }

            Animator[] childAnimators;
            if (getDecoratedBaseAdapter() is AnimationAdapter)
            {
                childAnimators = ((AnimationAdapter)getDecoratedBaseAdapter()).getAnimators(parent, view);
            }
            else
            {
                childAnimators = new Animator[0];
            }
            Animator[] animators     = getAnimators(parent, view);
            Animator   alphaAnimator = ObjectAnimator.OfFloat(view, ALPHA, 0, 1);

            Animator[] concatAnimators = AnimatorUtil.concatAnimators(childAnimators, animators, alphaAnimator);
            mViewAnimator.animateViewIfNecessary(position, view, concatAnimators);
        }
示例#2
0
        /**
         * Animates given View if necessary.
         *
         * @param position the position of the item the View represents.
         * @param view     the View that should be animated.
         * @param parent   the parent the View is hosted in.
         */
        private void animateViewIfNecessary(int position, View view, ViewGroup parent)
        {
            Animator[] childAnimators;
            if (getDecoratedBaseAdapter() is AnimationAdapter)
            {
                childAnimators = ((AnimationAdapter)getDecoratedBaseAdapter()).getAnimators(parent, view);
            }
            else
            {
                childAnimators = new Animator[0];
            }
            Animator alphaAnimator = ObjectAnimator.OfFloat(view, ALPHA, 0, 1);

            //assert mViewAnimator != null;
            mViewAnimator.animateViewIfNecessary(position, view, AnimatorUtil.concatAnimators(childAnimators, new Animator[0], alphaAnimator));
        }