public RecyclerViewOverScrollDecorAdapter(RecyclerView recyclerView) { mRecyclerView = recyclerView; final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (layoutManager instanceof LinearLayoutManager || layoutManager instanceof StaggeredGridLayoutManager) { final int orientation = (layoutManager instanceof LinearLayoutManager ? ((LinearLayoutManager) layoutManager).getOrientation() : ((StaggeredGridLayoutManager) layoutManager).getOrientation()); if (orientation == LinearLayoutManager.HORIZONTAL) { mImpl = new ImplHorizLayout(); } else { mImpl = new ImplVerticalLayout(); } } else { throw new IllegalArgumentException("Recycler views with custom layout managers are not supported by this adapter out of the box." + "Try implementing and providing an explicit 'impl' parameter to the other c'tors, or otherwise create a custom adapter subclass of your own."); } }