protected internal override long getDelayForView(android.view.View view)
        {
            android.view.ViewGroup.LayoutParams lp = view.getLayoutParams();
            android.view.animation.GridLayoutAnimationController.AnimationParameters @params =
                (android.view.animation.GridLayoutAnimationController.AnimationParameters)lp.layoutAnimationParameters;
            if (@params == null)
            {
                return(0);
            }
            int   column       = getTransformedColumnIndex(@params);
            int   row          = getTransformedRowIndex(@params);
            int   rowsCount    = @params.rowsCount;
            int   columnsCount = @params.columnsCount;
            long  duration     = mAnimation.getDuration();
            float columnDelay  = mColumnDelay * duration;
            float rowDelay     = mRowDelay * duration;
            float totalDelay;
            long  viewDelay;

            if (mInterpolator == null)
            {
                mInterpolator = new android.view.animation.LinearInterpolator();
            }
            switch (mDirectionPriority)
            {
            case PRIORITY_COLUMN:
            {
                viewDelay  = (long)(row * rowDelay + column * rowsCount * rowDelay);
                totalDelay = rowsCount * rowDelay + columnsCount * rowsCount * rowDelay;
                break;
            }

            case PRIORITY_ROW:
            {
                viewDelay  = (long)(column * columnDelay + row * columnsCount * columnDelay);
                totalDelay = columnsCount * columnDelay + rowsCount * columnsCount * columnDelay;
                break;
            }

            case PRIORITY_NONE:
            default:
            {
                viewDelay  = (long)(column * columnDelay + row * rowDelay);
                totalDelay = columnsCount * columnDelay + rowsCount * rowDelay;
                break;
            }
            }
            float normalizedDelay = viewDelay / totalDelay;

            normalizedDelay = mInterpolator.getInterpolation(normalizedDelay);
            return((long)(normalizedDelay * totalDelay));
        }
        private int getTransformedRowIndex(android.view.animation.GridLayoutAnimationController
                                           .AnimationParameters @params)
        {
            int index;

            switch (getOrder())
            {
            case ORDER_REVERSE:
            {
                index = @params.rowsCount - 1 - @params.row;
                break;
            }

            case ORDER_RANDOM:
            {
                if (mRandomizer == null)
                {
                    mRandomizer = new System.Random();
                }
                index = (int)(@params.rowsCount * Sharpen.Util.Random_NextFloat(mRandomizer));
                break;
            }

            case ORDER_NORMAL:
            default:
            {
                index = @params.row;
                break;
            }
            }
            int direction = mDirection & DIRECTION_VERTICAL_MASK;

            if (direction == DIRECTION_BOTTOM_TO_TOP)
            {
                index = @params.rowsCount - 1 - index;
            }
            return(index);
        }
Beispiel #3
0
		protected internal override void attachLayoutAnimationParameters(android.view.View
			 child, android.view.ViewGroup.LayoutParams @params, int index, int count)
		{
			android.view.animation.GridLayoutAnimationController.AnimationParameters animationParams
				 = (android.view.animation.GridLayoutAnimationController.AnimationParameters)@params
				.layoutAnimationParameters;
			if (animationParams == null)
			{
				animationParams = new android.view.animation.GridLayoutAnimationController.AnimationParameters
					();
				@params.layoutAnimationParameters = animationParams;
			}
			animationParams.count = count;
			animationParams.index = index;
			animationParams.columnsCount = mNumColumns;
			animationParams.rowsCount = count / mNumColumns;
			if (!mStackFromBottom)
			{
				animationParams.column = index % mNumColumns;
				animationParams.row = index / mNumColumns;
			}
			else
			{
				int invertedIndex = count - 1 - index;
				animationParams.column = mNumColumns - 1 - (invertedIndex % mNumColumns);
				animationParams.row = animationParams.rowsCount - 1 - invertedIndex / mNumColumns;
			}
		}