private View moveSelection(View oldSel,View newSel,int delta,int childrenLeft,int childrenRight){
  int fadingEdgeLength=getHorizontalFadingEdgeLength();
  final int selectedPosition=mSelectedPosition;
  View sel;
  final int leftSelectionPixel=getLeftSelectionPixel(childrenLeft,fadingEdgeLength,selectedPosition);
  final int rightSelectionPixel=getRightSelectionPixel(childrenLeft,fadingEdgeLength,selectedPosition);
  if (delta > 0) {
    oldSel=makeAndAddView(selectedPosition - 1,oldSel.getLeft(),true,mListPadding.top,false);
    final int dividerWidth=mDividerWidth;
    sel=makeAndAddView(selectedPosition,oldSel.getRight() + dividerWidth,true,mListPadding.top,true);
    if (sel.getRight() > rightSelectionPixel) {
      int spaceBefore=sel.getLeft() - leftSelectionPixel;
      int spaceAfter=sel.getRight() - rightSelectionPixel;
      int halfHorizontalSpace=(childrenRight - childrenLeft) / 2;
      int offset=Math.min(spaceBefore,spaceAfter);
      offset=Math.min(offset,halfHorizontalSpace);
      oldSel.offsetLeftAndRight(-offset);
      sel.offsetLeftAndRight(-offset);
    }
    if (!mStackFromRight) {
      fillLeft(mSelectedPosition - 2,sel.getLeft() - dividerWidth);
      adjustViewsLeftOrRight();
      fillRight(mSelectedPosition + 1,sel.getRight() + dividerWidth);
    }
 else {
      fillRight(mSelectedPosition + 1,sel.getRight() + dividerWidth);
      adjustViewsLeftOrRight();
      fillLeft(mSelectedPosition - 2,sel.getLeft() - dividerWidth);
    }
  }
 else   if (delta < 0) {
    if (newSel != null) {
      sel=makeAndAddView(selectedPosition,newSel.getLeft(),true,mListPadding.top,true);
    }
 else {
      sel=makeAndAddView(selectedPosition,oldSel.getLeft(),false,mListPadding.top,true);
    }
    if (sel.getLeft() < leftSelectionPixel) {
      int spaceBefore=leftSelectionPixel - sel.getLeft();
      int spaceAfter=rightSelectionPixel - sel.getRight();
      int halfHorizontalSpace=(childrenRight - childrenLeft) / 2;
      int offset=Math.min(spaceBefore,spaceAfter);
      offset=Math.min(offset,halfHorizontalSpace);
      sel.offsetLeftAndRight(offset);
    }
    fillBeforeAndAfter(sel,selectedPosition);
  }
 else {
    int oldLeft=oldSel.getLeft();
    sel=makeAndAddView(selectedPosition,oldLeft,true,mListPadding.top,true);
    if (oldLeft < childrenLeft) {
      int newRight=sel.getRight();
      if (newRight < childrenLeft + 20) {
        sel.offsetLeftAndRight(childrenLeft - sel.getLeft());
      }
    }
    fillBeforeAndAfter(sel,selectedPosition);
  }
  return sel;
}

private View moveSelection ( View oldSel , View newSel , int delta , int childrenLeft , int childrenRight ) { int fadingEdgeLength = getHorizontalFadingEdgeLength ( ) ; final int selectedPosition = mSelectedPosition ; View sel ; final int leftSelectionPixel = getLeftSelectionPixel ( childrenLeft , fadingEdgeLength , selectedPosition ) ; final int rightSelectionPixel = getRightSelectionPixel ( childrenLeft , fadingEdgeLength , selectedPosition ) ; if ( delta > 0 ) { oldSel = makeAndAddView ( selectedPosition - 1 , oldSel . getLeft ( ) , true , mListPadding . top , false ) ; final int dividerWidth = mDividerWidth ; sel = makeAndAddView ( selectedPosition , oldSel . getRight ( ) + dividerWidth , true , mListPadding . top , true ) ; if ( sel . getRight ( ) > rightSelectionPixel ) { int spaceBefore = sel . getLeft ( ) - leftSelectionPixel ; int spaceAfter = sel . getRight ( ) - rightSelectionPixel ; int halfHorizontalSpace = ( childrenRight - childrenLeft ) / 2 ; int offset = Math . min ( spaceBefore , spaceAfter ) ; offset = Math . min ( offset , halfHorizontalSpace ) ; oldSel . offsetLeftAndRight ( - offset ) ; sel . offsetLeftAndRight ( - offset ) ; } if ( ! mStackFromRight ) { fillLeft ( mSelectedPosition - 2 , sel . getLeft ( ) - dividerWidth ) ; adjustViewsLeftOrRight ( ) ; fillRight ( mSelectedPosition + 1 , sel . getRight ( ) + dividerWidth ) ; } else { fillRight ( mSelectedPosition + 1 , sel . getRight ( ) + dividerWidth ) ; adjustViewsLeftOrRight ( ) ; fillLeft ( mSelectedPosition - 2 , sel . getLeft ( ) - dividerWidth ) ; } } else if ( delta < 0 ) { if ( newSel != null ) { sel = makeAndAddView ( selectedPosition , newSel . getLeft ( ) , true , mListPadding . top , true ) ; } else { sel = makeAndAddView ( selectedPosition , oldSel . getLeft ( ) , false , mListPadding . top , true ) ; } if ( sel . getLeft ( ) < leftSelectionPixel ) { int spaceBefore = leftSelectionPixel - sel . getLeft ( ) ; int spaceAfter = rightSelectionPixel - sel . getRight ( ) ; int halfHorizontalSpace = ( childrenRight - childrenLeft ) / 2 ; int offset = Math . min ( spaceBefore , spaceAfter ) ; offset = Math . min ( offset , halfHorizontalSpace ) ; sel . offsetLeftAndRight ( offset ) ; } fillBeforeAndAfter ( sel , selectedPosition ) ; } else { int oldLeft = oldSel . getLeft ( ) ; sel = makeAndAddView ( selectedPosition , oldLeft , true , mListPadding . top , true ) ; if ( oldLeft < childrenLeft ) { int newRight = sel . getRight ( ) ; if ( newRight < childrenLeft + 20 ) { sel . offsetLeftAndRight ( childrenLeft - sel . getLeft ( ) ) ; } } fillBeforeAndAfter ( sel , selectedPosition ) ; } return sel ; }
fills the list based on positioning the new selection relative to the old selection . the new selection will be placed at , above , or below 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 list is then filled upwards and downwards from there .
