Buggy code:
public class SuperRecyclerView extends FrameLayout { protected int ITEM_LEFT_TO_LOAD_MORE = 10 ; protected ViewStub mProgress ; protected ViewStub mMoreProgress ; protected RecyclerView mRecycler ; protected ViewStub mEmpty ; protected boolean mClipToPadding ; protected int mPadding ; protected int mPaddingTop ; protected int mPaddingBottom ; protected int mPaddingLeft ; protected int mPaddingRight ; protected int mScrollbarStyle ; protected int mEmptyId ; protected int mMoreProgressId ; protected SuperRecyclerView . LAYOUT_MANAGER_TYPE layoutManagerType ; protected OnScrollListener mInternalOnScrollListener ; private OnScrollListener mSwipeDismissScrollListener ; protected OnScrollListener mExternalOnScrollListener ; protected OnMoreListener mOnMoreListener ; protected boolean isLoadingMore ; protected int mSelector ; protected SwipeRefreshLayout mPtrLayout ; protected int mSuperRecyclerViewMainLayout ; private int mProgressId ; public SwipeRefreshLayout getSwipeToRefresh ( ) { } public RecyclerView getRecyclerView ( ) { } public SuperRecyclerView ( Context context ) { } public SuperRecyclerView ( Context context , AttributeSet attrs ) { } public SuperRecyclerView ( Context context , AttributeSet attrs , int defStyle ) { } protected void initAttrs ( AttributeSet attrs ) { } private void initView ( ) { } protected void initRecyclerView ( View view ) { View recyclerView = view . findViewById ( list ) ; if ( recyclerView instanceof RecyclerView ) mRecycler = ( ( RecyclerView ) ( recyclerView ) ) ; else throw new IllegalArgumentException ( "SuperRecyclerView<seq2seq4repair_space>works<seq2seq4repair_space>with<seq2seq4repair_space>a<seq2seq4repair_space>RecyclerView!" ) ; if ( ( mRecycler ) != null ) { mRecycler . setClipToPadding ( mClipToPadding ) ; mInternalOnScrollListener = new RecyclerView . OnScrollListener ( ) { private int [ ] lastPositions ; @ Override public void onScrolled ( RecyclerView recyclerView , int dx , int dy ) { super . onScrolled ( recyclerView , dx , dy ) ; RecyclerView . LayoutManager layoutManager = recyclerView . getLayoutManager ( ) ; int visibleItemCount = layoutManager . getChildCount ( ) ; int totalItemCount = layoutManager . getItemCount ( ) ; int lastVisibleItemPosition = - 1 ; if ( ( layoutManagerType ) == null ) { if ( layoutManager instanceof LinearLayoutManager ) { layoutManagerType = SuperRecyclerView . LAYOUT_MANAGER_TYPE . LINEAR ; } else if ( layoutManager instanceof GridLayoutManager ) { layoutManagerType = SuperRecyclerView . LAYOUT_MANAGER_TYPE . GRID ; } else if ( layoutManager instanceof StaggeredGridLayoutManager ) { layoutManagerType = SuperRecyclerView . LAYOUT_MANAGER_TYPE . STAGGERED_GRID ; } else { throw new RuntimeException ( "Unsupported<seq2seq4repair_space>LayoutManager<seq2seq4repair_space>used.<seq2seq4repair_space>Valid<seq2seq4repair_space>ones<seq2seq4repair_space>are<seq2seq4repair_space>LinearLayoutManager,<seq2seq4repair_space>GridLayoutManager<seq2seq4repair_space>and<seq2seq4repair_space>StaggeredGridLayoutManager" ) ; } } switch ( layoutManagerType ) { case LINEAR : lastVisibleItemPosition = ( ( LinearLayoutManager ) ( layoutManager ) ) . findLastVisibleItemPosition ( ) ; break ; case GRID : lastVisibleItemPosition = ( ( GridLayoutManager ) ( layoutManager ) ) . findLastVisibleItemPosition ( ) ; break ; case STAGGERED_GRID : StaggeredGridLayoutManager staggeredGridLayoutManager = ( ( StaggeredGridLayoutManager ) ( layoutManager ) ) ; if ( ( lastPositions ) == null ) lastPositions = new int [ staggeredGridLayoutManager . getSpanCount ( ) ] ; staggeredGridLayoutManager . findLastVisibleItemPositions ( lastPositions ) ; lastVisibleItemPosition = findMax ( lastPositions ) ; break ; } <START_BUG> if ( ( ( ( totalItemCount - lastVisibleItemPosition ) == ( ITEM_LEFT_TO_LOAD_MORE ) ) || ( ( ( totalItemCount - lastVisibleItemPosition ) == 0 ) && ( totalItemCount > visibleItemCount ) ) ) && ( ! ( isLoadingMore ) ) ) { <END_BUG> isLoadingMore = true ; if ( ( mOnMoreListener ) != null ) { mMoreProgress . setVisibility ( VISIBLE ) ; mOnMoreListener . onMoreAsked ( mRecycler . getAdapter ( ) . getItemCount ( ) , ITEM_LEFT_TO_LOAD_MORE , lastVisibleItemPosition ) ; } } if ( ( mExternalOnScrollListener ) != null ) mExternalOnScrollListener . onScrolled ( recyclerView , dx , dy ) ; if ( ( mSwipeDismissScrollListener ) != null ) mSwipeDismissScrollListener . onScrolled ( recyclerView , dx , dy ) ; } @ Override public void onScrollStateChanged ( RecyclerView recyclerView , int newState ) { super . onScrollStateChanged ( recyclerView , newState ) ; if ( ( mExternalOnScrollListener ) != null ) mExternalOnScrollListener . onScrollStateChanged ( recyclerView , newState ) ; if ( ( mSwipeDismissScrollListener ) != null ) mSwipeDismissScrollListener . onScrollStateChanged ( recyclerView , newState ) ; } } ; mRecycler . setOnScrollListener ( mInternalOnScrollListener ) ; if ( ( mSelector ) != 0 ) if ( ( mPadding ) != ( - 1.0F ) ) { mRecycler . setPadding ( mPadding , mPadding , mPadding , mPadding ) ; } else { mRecycler . setPadding ( mPaddingLeft , mPaddingTop , mPaddingRight , mPaddingBottom ) ; } if ( ( mScrollbarStyle ) != ( - 1 ) ) mRecycler . setScrollBarStyle ( mScrollbarStyle ) ; } } private int findMax ( int [ ] lastPositions ) { } public void setLayoutManager ( RecyclerView . LayoutManager manager ) { } public void setAdapter ( RecyclerView . Adapter adapter ) { } public void setupSwipeToDismiss ( final SwipeDismissRecyclerViewTouchListener . DismissCallbacks listener ) { } public void clear ( ) { } public void showProgress ( ) { } public void showRecycler ( ) { } public void showMoreProgress ( ) { } public void hideMoreProgress ( ) { } public void setRefreshListener ( SwipeRefreshLayout . OnRefreshListener listener ) { } public void setRefreshingColorResources ( @ ColorRes int colRes1 , @ ColorRes int colRes2 , @ ColorRes int colRes3 , @ ColorRes int colRes4 ) { } public void setRefreshingColor ( int col1 , int col2 , int col3 , int col4 ) { } public void hideProgress ( ) { } public void hideRecycler ( ) { } public void setOnScrollListener ( RecyclerView . OnScrollListener listener ) { } public void addOnItemTouchListener ( RecyclerView . OnItemTouchListener listener ) { } public void removeOnItemTouchListener ( RecyclerView . OnItemTouchListener listener ) { } public Adapter getAdapter ( ) { } public void setupMoreListener ( OnMoreListener onMoreListener , int max ) { } public void setOnMoreListener ( OnMoreListener onMoreListener ) { } public void setNumberBeforeMoreIsCalled ( int max ) { } public boolean isLoadingMore ( ) { } public void setLoadingMore ( boolean isLoadingMore ) { } public void removeMoreListener ( ) { } public void setOnTouchListener ( OnTouchListener listener ) { } public void addItemDecoration ( RecyclerView . ItemDecoration itemDecoration ) { }

Fix:
if ( ( ( ( totalItemCount - lastVisibleItemPosition ) <= ( ITEM_LEFT_TO_LOAD_MORE ) ) || ( ( ( totalItemCount - lastVisibleItemPosition ) == 0 ) && ( totalItemCount > visibleItemCount ) ) ) && ( ! ( isLoadingMore ) ) ) {