Why findLastCompletelyVisibleItemPosition() is returning -1?
<p>I am trying to do endless recycler view, using pagination in a fragment .<br>
 But facing problems as follows.</p>

<ol>
<li>findLastCompletlyVisibleItemPosition() or findFirstCompletelyVisibleItemPosition() is returning only -1.</li>
<li>if setNestedScrollingEnabled(false), then onScrollStateChanged is not working</li>
</ol>

<p>Below is a sample of my code.  `</p>

<pre><code>        recyclerView = (RecyclerView) view.findViewById(R.id.recycler1);

        //recyclerView.setNestedScrollingEnabled(false);                                              // Smooth Scrolling
         mLayoutManager = new LinearLayoutManager(getActivity());

        lastVisiblePosition = mLayoutManager.findLastVisibleItemPosition();
        firstVisibleItemPosition = mLayoutManager.findFirstCompletelyVisibleItemPosition();
        Log.i("sandi", String.valueOf(firstVisibleItemPosition));
        load = new LoadAdapter(getActivity(), grid_list);
        recyclerView.setLayoutManager(mLayoutManager);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(load);
        mProgressDialog.dismiss();

        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                int threshold =1;
                int count = recyclerView.getChildCount();



                Log.i("sand", String.valueOf(count));

                if (newState == SCROLL_STATE_IDLE ) {
                    if (lastVisiblePosition &gt;= count
                            - threshold) {
                        // Execute LoadMoreDataTask AsyncTask

                        Log.i("sand","stopped");
                        new LoadMoreDataTask().execute();
                    }
                } else {
                    Log.i("sand","not stopped");
                }
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
            }
        });
    }
</code></pre>

<p><strong>EDIT</strong><br>
The solution of this problem is in the comments section.</p>