int getSnappedPosition(RecyclerView recyclerView) {
        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();

        if (layoutManager instanceof LinearLayoutManager) {
            if (gravity == Gravity.START || gravity == Gravity.TOP) {
                return ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
            } else if (gravity == Gravity.END || gravity == Gravity.BOTTOM) {
                return ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
            }
        }

        return RecyclerView.NO_POSITION;
    }
Returns the first view that we should snap to.

@param layoutManager the recyclerview's layout manager
@param helper        orientation helper to calculate view sizes
@return the first view in the LayoutManager to snap to
cosmocalendar/src/main/java/com/applikeysolutions/cosmocalendar/utils/snap/GravityDelegate.java