title: How to Load Json in Endless Recycler Veiw with Retrofit
body: <p>I try to implement Endless Recycler View with my Json Response .</p>
  
  <p>This is My Json Response <a href="http://www.aparat.com/etc/api/categoryvideos" rel="nofollow">Link</a></p>
  
  <p>I Generate my models with jsonschema2pojo.org and I load the data in my recyclerview successfully .</p>
  
  <p>But I need to implement endless recycler view :</p>
  
  <p>This is my RecyclerAdapter :</p>
  
  <pre><code>public class AparatAdapter extends RecyclerView.Adapter&lt;AparatAdapter.ViewHolder&gt; {
  
      private Context context;
      private ArrayList&lt;Categoryvideo&gt; categoryVideos;
  
      //=============================constructor
      public AparatAdapter(Context context, ArrayList&lt;Categoryvideo&gt; categoryVideos) {
          this.context = context;
          this.categoryVideos = categoryVideos;
      }
      //=============================viewholder
      public class ViewHolder extends RecyclerView.ViewHolder{
          private TextView txtTitle ,txtCount ,txtSender ,txtDate;
          private ImageView imgRow;
          public ViewHolder(View itemView) {
              super(itemView);
              txtTitle = (TextView)itemView.findViewById(R.id.txt_title_row);
              txtCount = (TextView)itemView.findViewById(R.id.txt_count_dynamic_row);
              txtSender = (TextView)itemView.findViewById(R.id.txt_sender_dynamic_row);
              txtDate = (TextView)itemView.findViewById(R.id.txt_date_dynamic_row);
              imgRow = (ImageView)itemView.findViewById(R.id.img_row);
          }
      }
  
      //================================oncreateviewholder
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_layout, parent,false);
          return new ViewHolder(view);
      }
  
      //================================= onbindviewholder
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
  
          holder.txtTitle.setText(categoryVideos.get(position).getTitle());
          holder.txtCount.setText(categoryVideos.get(position).getVisitCnt().toString());
          holder.txtSender.setText(categoryVideos.get(position).getSenderName());
          holder.txtDate.setText(categoryVideos.get(position).getSdate().toString());
          Glide.with(holder.itemView.getContext()).load(categoryVideos.get(position).getSmallPoster())
                  .into(holder.imgRow);
      }
  
      //==================================getitemcount
  
      @Override
      public int getItemCount() {
          return categoryVideos.size();
      }
  }
  </code></pre>
  
  <p>And This is the activity where i load the json in that with retrofit :</p>
  
  <pre><code>public class SargarmiActivity extends AppCompatActivity {
      private RecyclerView recyclerView;
      private AparatAdapter adapter;
      private LinearLayoutManager layoutManager;
      private ArrayList&lt;Categoryvideo&gt; categoryvideos;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_sargarmi);
          initViews();
      }
      //=================================================
  
      private void initViews() {
          recyclerView = (RecyclerView) findViewById(R.id.recycler_sargarmi);
          recyclerView.setHasFixedSize(true);
          layoutManager = new LinearLayoutManager(SargarmiActivity.this);
          recyclerView.setLayoutManager(layoutManager);
          sendRequest();
      }
  
      //=================================================
      private void sendRequest() {
          recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(layoutManager) {
              @Override
              public void onLoadMore(int page, int totalItemsCount) {
                  loadMore();
              }
          });
          getData();
      }
  
  
  
      //=======================================================
      private void getData() {
          //1
          Retrofit retrofit = new Retrofit.Builder()
                  .baseUrl("http://www.aparat.com/etc/api/")
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
          //2
          ApiInterface request = retrofit.create(ApiInterface.class);
  
          //3
          Call&lt;JSONResponse&gt; call = request.getJsonResponse();
  
          //4
          call.enqueue(new Callback&lt;JSONResponse&gt;() {
              @Override
              public void onResponse(Call&lt;JSONResponse&gt; call, Response&lt;JSONResponse&gt; response) {
                  if (response.isSuccessful()) {
                      JSONResponse jsonResponse = response.body();
                      categoryvideos = new ArrayList&lt;&gt;(jsonResponse.getCategoryvideos());
                      adapter = new AparatAdapter(SargarmiActivity.this, categoryvideos);
                      recyclerView.setAdapter(adapter);
  
                  } else {
                      Toast.makeText(SargarmiActivity.this, "Error darim else onresponse", Toast.LENGTH_SHORT).show();
                  }
              }
  
              @Override
              public void onFailure(Call&lt;JSONResponse&gt; call, Throwable t) {
                  Toast.makeText(SargarmiActivity.this, "Error darim onFailure()", Toast.LENGTH_SHORT).show();
              }
          });
      }
  
      //=============== Load more Endless =====================
      private void loadMore() {
  
      }
  }
  </code></pre>
  
  <p>As you can see in <a href="http://www.aparat.com/etc/api/categoryvideos" rel="nofollow">json</a> my pagination url embed in ui object . and i don't know what should i write in the loadmore() method in my activity.</p>