Android Endless Recyclerview in webservice,reloads to first position

441 views Asked by At

I have a endless recycler view in my program.I referred this link

http://android-pratap.blogspot.in/2015/01/endless-recyclerview-onscrolllistener.html

It works fine without web service.But reloads to previous position in second call of webservice

 mAdapter.setOnLoadMoreListener(new OnLoadMoreListener() {

                    @Override
                    public void onLoadMore() {
                        System.out.println("LOAD MORE");
                        details.add(null);
                        mAdapter.notifyItemInserted(details.size() - 1);
                        System.out.println("Exception Loadmore calling");
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                               System.out.println("Exception 2");
                                details.remove(details.size() - 1);
                                System.out.println("Exception 3");
                              mAdapter.notifyItemRemoved(details.size());
                                System.out.println("Exception 4");
                            page++;
                                System.out.println("Exception 5");
                                if (page < totalPages) {
                                    System.out.println("Exception 6");
                                    try {
                                        System.out.println("Exception 7");
                                        volleydata();
                                        System.out.println("Exception 8");
                                           mAdapter.notifyItemInserted(details.size());
                                        System.out.println("Exception 9");
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }
                                    System.out.println("Exception 10");

                                    mAdapter.notifyDataSetChanged();

                                }
                            }
                        }, 1000);
                        System.out.println("load");
                    }
                });
0

There are 0 answers