title: How to implement a lazy loading recyclerView adapter like realm recyclerView adapter using kotlin
body: <p>I need to implement a recyclerView that shows my queries on Parse, so I've done it:</p>
  
  <pre><code> private class Pagination extends RecyclerView.OnScrollListener{
  
      @Override
      public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
          super.onScrolled(recyclerView, dx, dy);
  
          visibleItemCount = manager.getChildCount();
          totalItemCount = manager.getItemCount();
          firstVisibleItemPosition = manager.findFirstVisibleItemPosition();
  
  
          if (!isLoading &amp;&amp; !isLastPage) {
              if ((visibleItemCount + firstVisibleItemPosition) &gt;= totalItemCount
                      &amp;&amp; firstVisibleItemPosition &gt;= 0
                      &amp;&amp; totalItemCount &gt;= PAGINATION) {
                  isLoading = true;
  
                  new Handler().postDelayed(new Runnable() {
                      @Override
                      public void run() {
                          loadData();
                      }
                  }, 2000);
              }
          }
      }
  }
  </code></pre>
  
  <p>and it works well. But some months ago I've used realm recyclerView adapter that works without pagination (and it works very well because I've 50k items to show) and I want to make an adapter like this. I've also use Kotlin and I've seen the concept of a lazy variable:</p>
  
  <pre><code>val lazyValue: String by lazy {
  println("computed!")
  "Hello"
  }
  </code></pre>
  
  <p>but I don't know how to use it to make adapter for this reason: now when I do a query to parse it's something like this:</p>
  
  <pre><code> val dishes = ParseQuery.getQuery&lt;ParseObject&gt;("Books").setSkip(index).setLimit(pagination)
  
   dishes.findInBackground { objects, e -&gt; e?.let { listener?.onPaginationError(e.message)  } ?:run { createNewDish(objects,listener,false)  } }
  </code></pre>
  
  <p>and how it works when I use a lazy approach? I need to download all items or I need also to paginate?</p>