private View moveSelection(int delta,int childrenLeft,int childrenRight){
  if (DEBUG)   Log.i(TAG,"moveSelection() delta: " + delta + " childrenLeft: "+ childrenLeft+ CHILDREN_RIGHT+ childrenRight+ M_FIRST_POSITION+ mFirstPosition);
  final int fadingEdgeLength=getHorizontalFadingEdgeLength();
  final int selectedPosition=mSelectedPosition;
  final int numRows=mNumRows;
  final int horizontalSpacing=mHorizontalSpacing;
  int oldColumnStart;
  int columnStart;
  int columnEnd=-1;
  if (!mStackFromBottom) {
    oldColumnStart=(selectedPosition - delta) - ((selectedPosition - delta) % numRows);
    columnStart=selectedPosition - (selectedPosition % numRows);
  }
 else {
    int invertedSelection=mItemCount - 1 - selectedPosition;
    columnEnd=mItemCount - 1 - (invertedSelection - (invertedSelection % numRows));
    columnStart=Math.max(0,columnEnd - numRows + 1);
    invertedSelection=mItemCount - 1 - (selectedPosition - delta);
    oldColumnStart=mItemCount - 1 - (invertedSelection - (invertedSelection % numRows));
    oldColumnStart=Math.max(0,oldColumnStart - numRows + 1);
  }
  final int rowDelta=columnStart - oldColumnStart;
  final int leftSelectionPixel=getLeftSelectionPixel(childrenLeft,fadingEdgeLength,columnStart);
  final int rightSelectionPixel=getRightSelectionPixel(childrenRight,fadingEdgeLength,numRows,columnStart);
  mFirstPosition=columnStart;
  View sel;
  View referenceView;
  if (rowDelta > 0) {
    final int oldRight=mReferenceViewInSelectedRow == null ? 0 : mReferenceViewInSelectedRow.getRight();
    sel=makeColumn(mStackFromBottom ? columnEnd : columnStart,oldRight + horizontalSpacing,true);
    referenceView=mReferenceView;
    adjustForRightFadingEdge(referenceView,leftSelectionPixel,rightSelectionPixel);
  }
 else   if (rowDelta < 0) {
    final int oldTop=mReferenceViewInSelectedRow == null ? 0 : mReferenceViewInSelectedRow.getLeft();
    sel=makeColumn(mStackFromBottom ? columnEnd : columnStart,oldTop - horizontalSpacing,false);
    referenceView=mReferenceView;
    adjustForLeftFadingEdge(referenceView,leftSelectionPixel,rightSelectionPixel);
  }
 else {
    final int oldTop=mReferenceViewInSelectedRow == null ? 0 : mReferenceViewInSelectedRow.getLeft();
    sel=makeColumn(mStackFromBottom ? columnEnd : columnStart,oldTop,true);
    referenceView=mReferenceView;
  }
  if (!mStackFromBottom) {
    fillLeft(columnStart - numRows,referenceView.getLeft() - horizontalSpacing);
    adjustViewsLeftOrRight();
    fillRight(columnStart + numRows,referenceView.getRight() + horizontalSpacing);
  }
 else {
    fillRight(columnStart + numRows,referenceView.getRight() + horizontalSpacing);
    adjustViewsLeftOrRight();
    fillLeft(columnStart - 1,referenceView.getLeft() - horizontalSpacing);
  }
  return sel;
}

private View moveSelection ( int delta , int childrenLeft , int childrenRight ) { if ( DEBUG ) Log . i ( TAG , "moveSelection() delta: " + delta + " childrenLeft: " + childrenLeft + CHILDREN_RIGHT + childrenRight + M_FIRST_POSITION + mFirstPosition ) ; final int fadingEdgeLength = getHorizontalFadingEdgeLength ( ) ; final int selectedPosition = mSelectedPosition ; final int numRows = mNumRows ; final int horizontalSpacing = mHorizontalSpacing ; int oldColumnStart ; int columnStart ; int columnEnd = - 1 ; if ( ! mStackFromBottom ) { oldColumnStart = ( selectedPosition - delta ) - ( ( selectedPosition - delta ) % numRows ) ; columnStart = selectedPosition - ( selectedPosition % numRows ) ; } else { int invertedSelection = mItemCount - 1 - selectedPosition ; columnEnd = mItemCount - 1 - ( invertedSelection - ( invertedSelection % numRows ) ) ; columnStart = Math . max ( 0 , columnEnd - numRows + 1 ) ; invertedSelection = mItemCount - 1 - ( selectedPosition - delta ) ; oldColumnStart = mItemCount - 1 - ( invertedSelection - ( invertedSelection % numRows ) ) ; oldColumnStart = Math . max ( 0 , oldColumnStart - numRows + 1 ) ; } final int rowDelta = columnStart - oldColumnStart ; final int leftSelectionPixel = getLeftSelectionPixel ( childrenLeft , fadingEdgeLength , columnStart ) ; final int rightSelectionPixel = getRightSelectionPixel ( childrenRight , fadingEdgeLength , numRows , columnStart ) ; mFirstPosition = columnStart ; View sel ; View referenceView ; if ( rowDelta > 0 ) { final int oldRight = mReferenceViewInSelectedRow == null ? 0 : mReferenceViewInSelectedRow . getRight ( ) ; sel = makeColumn ( mStackFromBottom ? columnEnd : columnStart , oldRight + horizontalSpacing , true ) ; referenceView = mReferenceView ; adjustForRightFadingEdge ( referenceView , leftSelectionPixel , rightSelectionPixel ) ; } else if ( rowDelta < 0 ) { final int oldTop = mReferenceViewInSelectedRow == null ? 0 : mReferenceViewInSelectedRow . getLeft ( ) ; sel = makeColumn ( mStackFromBottom ? columnEnd : columnStart , oldTop - horizontalSpacing , false ) ; referenceView = mReferenceView ; adjustForLeftFadingEdge ( referenceView , leftSelectionPixel , rightSelectionPixel ) ; } else { final int oldTop = mReferenceViewInSelectedRow == null ? 0 : mReferenceViewInSelectedRow . getLeft ( ) ; sel = makeColumn ( mStackFromBottom ? columnEnd : columnStart , oldTop , true ) ; referenceView = mReferenceView ; } if ( ! mStackFromBottom ) { fillLeft ( columnStart - numRows , referenceView . getLeft ( ) - horizontalSpacing ) ; adjustViewsLeftOrRight ( ) ; fillRight ( columnStart + numRows , referenceView . getRight ( ) + horizontalSpacing ) ; } else { fillRight ( columnStart + numRows , referenceView . getRight ( ) + horizontalSpacing ) ; adjustViewsLeftOrRight ( ) ; fillLeft ( columnStart - 1 , referenceView . getLeft ( ) - horizontalSpacing ) ; } return sel ; }
fills the grid based on positioning the new selection relative to the old selection . the new selection will be placed at , to left of , or to right of the location of the new selection depending on how the selection is moving . the selection will then be pinned to the visible part of the screen , excluding the edges that are faded . the grid is then filled leftwards and rightwards from there .
