Buggy code:
public class DraggableGridView extends ViewGroup implements View . OnClickListener , View . OnLongClickListener , View . OnTouchListener { private static final float CHILD_RATIO = 0.95F ; private static final int ANIM_DURATION = 150 ; private static final int COL_COUNT = 3 ; protected int mChildSize ; protected int mPadding ; protected int mLeftOffset ; protected int mScroll = 0 ; protected float mLastDelta = 0 ; protected Handler mHandler = new Handler ( ) ; protected int mDragged = - 1 ; protected int mLastX = - 1 ; protected int mLastY = - 1 ; protected int mLastTarget = - 1 ; protected boolean mEnabled = true ; protected boolean mTouching = false ; protected boolean mIsDelete = false ; protected final ArrayList < Integer > mNewPositions = new ArrayList < Integer > ( ) ; protected DraggableGridView . OnRearrangeListener mOnRearrangeListener ; protected OnClickListener mSecondaryOnClickListener ; private OnItemClickListener mOnItemClickListener ; private boolean mUseMainTiles = false ; private int mMaxItemCount = - 1 ; protected Runnable mUpdateTask = new Runnable ( ) { public void run ( ) { } } ; public DraggableGridView ( Context context , AttributeSet attrs ) { } public void setMaxItemCount ( int count ) { } protected void setListeners ( ) { } @ Override protected void onAttachedToWindow ( ) { } @ Override protected void onDetachedFromWindow ( ) { } @ Override public void setOnClickListener ( OnClickListener l ) { } @ Override public void addView ( View child , int index ) { } @ Override public void addView ( View child ) { } @ Override public void removeViewAt ( int index ) { } @ Override protected void onLayout ( boolean changed , int l , int t , int r , int b ) { } @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { } @ Override protected int getChildDrawingOrder ( int childCount , int i ) { } public int getIndexFromCoordinate ( int x , int y ) { int row = getColOrRowFromCoordinate ( ( y + ( mScroll ) ) ) ; int col = getColFromCoordinate ( row , x ) ; if ( ( col == ( - 1 ) ) || ( row == ( - 1 ) ) ) { return - 1 ; } int index = 0 ; index = ( row * ( DraggableGridView . COL_COUNT ) ) + col ; if ( mUseMainTiles ) { if ( ( row == 0 ) && ( col == ( ( DraggableGridView . COL_COUNT ) - 1 ) ) ) { return - 1 ; } if ( row > 0 ) { index -- ; } } <START_BUG> if ( index > ( getChildCount ( ) ) ) { <END_BUG> return - 1 ; } return index ; } protected int getColFromCoordinate ( int row , int coordinate ) { } protected int getColOrRowFromCoordinate ( int coordinate ) { } protected int getTargetFromCoordinate ( int x , int y ) { } protected Point getCoordinateFromIndex ( int index ) { } public int getIndexOf ( View child ) { } @ Override public void onClick ( View view ) { } void updateAddDeleteState ( ) { } @ Override public boolean onLongClick ( View view ) { } @ Override public boolean onTouch ( View view , MotionEvent event ) { } protected List < Animator > animateDragging ( boolean start ) { } protected void startAnimation ( List < Animator > animators ) { } protected void animateGap ( int target ) { } private static class ChildReorderInfo { View view ; float lastX ; float lastY ; } protected void reorderChildren ( int dragged , List < Animator > animators ) { } public void scrollToTop ( ) { } public void scrollToBottom ( ) { } protected void clampScroll ( ) { } protected int getMaxScroll ( ) { } public int getLastIndex ( ) { } public void setOnRearrangeListener ( DraggableGridView . OnRearrangeListener l ) { } public void setOnItemClickListener ( AdapterView . OnItemClickListener l ) { } public interface OnRearrangeListener { public abstract void onChange ( ) { } } }

Fix:
if ( index >= ( getChildCount ( ) ) ) {