@Override protected boolean arrowScroll(int direction){
  final int selectedPosition=mSelectedPosition;
  final int numColumns=mNumColumns;
  int startOfRowPos;
  int endOfRowPos;
  boolean moved=false;
  if (!mStackFromBottom) {
    startOfRowPos=(selectedPosition / numColumns) * numColumns;
    endOfRowPos=Math.min(startOfRowPos + numColumns - 1,mItemCount - 1);
  }
 else {
    final int invertedSelection=mItemCount - 1 - selectedPosition;
    endOfRowPos=mItemCount - 1 - (invertedSelection / numColumns) * numColumns;
    startOfRowPos=Math.max(0,endOfRowPos - numColumns + 1);
  }
switch (direction) {
case FOCUS_UP:
    if (startOfRowPos > 0) {
      mLayoutMode=LAYOUT_MOVE_SELECTION;
      setSelectionInt(Math.max(0,selectedPosition - numColumns));
      moved=true;
    }
  break;
case FOCUS_DOWN:
if (endOfRowPos < mItemCount - 1) {
  mLayoutMode=LAYOUT_MOVE_SELECTION;
  setSelectionInt(Math.min(selectedPosition + numColumns,mItemCount - 1));
  moved=true;
}
break;
case FOCUS_LEFT:
if (selectedPosition > startOfRowPos) {
mLayoutMode=LAYOUT_MOVE_SELECTION;
setSelectionInt(Math.max(0,selectedPosition - 1));
moved=true;
}
break;
case FOCUS_RIGHT:
if (selectedPosition < endOfRowPos) {
mLayoutMode=LAYOUT_MOVE_SELECTION;
setSelectionInt(Math.min(selectedPosition + 1,mItemCount - 1));
moved=true;
}
break;
}
if (moved) {
playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
invokeOnItemScrollListener();
}
if (moved) {
}
return moved;
}

@ Override protected boolean arrowScroll ( int direction ) { final int selectedPosition = mSelectedPosition ; final int numColumns = mNumColumns ; int startOfRowPos ; int endOfRowPos ; boolean moved = false ; if ( ! mStackFromBottom ) { startOfRowPos = ( selectedPosition / numColumns ) * numColumns ; endOfRowPos = Math . min ( startOfRowPos + numColumns - 1 , mItemCount - 1 ) ; } else { final int invertedSelection = mItemCount - 1 - selectedPosition ; endOfRowPos = mItemCount - 1 - ( invertedSelection / numColumns ) * numColumns ; startOfRowPos = Math . max ( 0 , endOfRowPos - numColumns + 1 ) ; } switch ( direction ) { case FOCUS_UP : if ( startOfRowPos > 0 ) { mLayoutMode = LAYOUT_MOVE_SELECTION ; setSelectionInt ( Math . max ( 0 , selectedPosition - numColumns ) ) ; moved = true ; } break ; case FOCUS_DOWN : if ( endOfRowPos < mItemCount - 1 ) { mLayoutMode = LAYOUT_MOVE_SELECTION ; setSelectionInt ( Math . min ( selectedPosition + numColumns , mItemCount - 1 ) ) ; moved = true ; } break ; case FOCUS_LEFT : if ( selectedPosition > startOfRowPos ) { mLayoutMode = LAYOUT_MOVE_SELECTION ; setSelectionInt ( Math . max ( 0 , selectedPosition - 1 ) ) ; moved = true ; } break ; case FOCUS_RIGHT : if ( selectedPosition < endOfRowPos ) { mLayoutMode = LAYOUT_MOVE_SELECTION ; setSelectionInt ( Math . min ( selectedPosition + 1 , mItemCount - 1 ) ) ; moved = true ; } break ; } if ( moved ) { playSoundEffect ( SoundEffectConstants . getContantForFocusDirection ( direction ) ) ; invokeOnItemScrollListener ( ) ; } if ( moved ) { } return moved ; }
scrolls to the next or previous item , horizontally or vertically .
