title: How to implement pagination with recyclerview via api url indexing
body: <p>I know the title seems weird, but basically what I want is to apply pagination to my list and control it using the url api endpoint as a parameter.!</p>
  
  <p>so the endpoint looks like this for example > <code>www.someapi.com/josn/list?pageIndex=1</code></p>
  
  <p>and it will give a response with array of 10 items, and if I want more I have to change the index of the parameter to 2 and so on.!</p>
  
  <p>response</p>
  
  <pre><code>{
      "Succeeded": true,
      "AvailableChallenge": true,
      "DebugError": "",
      "NextPage": 2,
      "AllPages": 2,
      "Challenges": [
          {
              "ID": 114,
              "Title": "Amet sit id ratione dolorem numquam"
          },
          {
              "ID": 114,
              "Title": "Amet sit id ratione dolorem numquam"
          }
          ...
          ..
          .
          ]
   }
  </code></pre>
  
  <p>I tied everything, but couldn't get it done correctly, I have tried most of the solutions in <strong><a href="https://stackoverflow.com/questions/26543131/how-to-implement-endless-list-with-recyclerview">here</a></strong> and no luck. 
  I've also tried to use these two library <strong><a href="https://github.com/MarkoMilos/Paginate" rel="nofollow noreferrer">Paginate</a></strong> &amp; <strong><a href="https://github.com/hendraanggrian/recyclerview-paginated" rel="nofollow noreferrer">recyclerview-paginated</a></strong> and even this <strong><a href="http://%20https://github.com/Malinskiy/SuperRecyclerView" rel="nofollow noreferrer">SuperRecyclerView</a></strong>. but it didn't work.!</p>
  
  <p>Any help with the best logic for controlling this will help a lot.</p>
  
  <hr>
  
  <p><strong>Code for <a href="http://%20https://github.com/Malinskiy/SuperRecyclerView" rel="nofollow noreferrer">SuperRecyclerView</a></strong> </p>
  
  <pre><code>public class ChallengesListFragment extends BaseFragment {
  
    private int pageNumber = 1; 
    private SuperRecyclerView recyclerview;
    private ArrayList&lt;ChallengeActive&gt; data;
    private ChallengesAdapter adapter;
  
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_challenges_list, container, false);
      initView(rootView);
      initRecycler();
      getData(1);
      return rootView;
    }
  
   private void initRecycler() {
      data = new ArrayList&lt;&gt;();
  
      final RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
      recyclerview.setLayoutManager(mLayoutManager);
      adapter = new ChallengesAdapter(data, getActivity(), this); 
      recyclerview.setAdapter(adapter);
  
      recyclerview.setupMoreListener(new OnMoreListener() {
        @Override
        public void onMoreAsked(int overallItemsCount, int itemsBeforeMore, int maxLastVisiblePosition) {
  
          pageNumber++;
          getData(maxLastVisiblePosition);
        }
      }, 10);
  
      recyclerview.setRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
          pageNumber = 1;
          getData(pageNumber);
        }
      });
  
    }
  
    private void getData(final int pageNumber) {
  
        WebRequests.GetActiveChallenges(pageNumber, new onResult() {
        @Override
        public void onSuccess(Object object) {
          ArrayList&lt;ChallengeActive&gt; list = (ArrayList&lt;ChallengeActive&gt;) object;
          data.clear();
          data.addAll(list);
          adapter.notifyDataSetChanged();  
        }
  
        @Override
        public void onFail(Object object) {
          Toast.makeText(getActivity(), "Something went wrong, try again later",
              Toast.LENGTH_SHORT).show(); 
        }
      }); 
    } 
  }  
  </code></pre>