title: RecyclerView load more with ProgressBar error
body: <p>I'm trying to create <code>Recyclerview</code> onLoadMore with <code>ProgressBar</code> at the bottom. I've tried <a href="https://stackoverflow.com/a/30691092/5649216">this solution</a>, but method onLoadMore in my <code>Activity</code> is never called. Please, help me.</p>
  
  <p>Here is my <code>Adapter</code>:</p>
  
  <pre><code>public class NewsAdapterTest extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {
  
      private ArrayList&lt;NewsDataModel&gt; dataSet;
      private Context context;
  
      private final int VIEW_ITEM = 1;
      private final int VIEW_PROG = 0;
  
      // The minimum amount of items to have below your current scroll position before loading more.
      private int visibleThreshold = 2;
      private int lastVisibleItem, totalItemCount;
      private boolean loading;
      private OnLoadMoreListener onLoadMoreListener;
  
      public NewsAdapterTest(ArrayList&lt;NewsDataModel&gt; data, Context context, RecyclerView recyclerView) {
          this.dataSet = data;
          this.context = context;
  
  
          if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
  
              final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
              recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
                  @Override
                  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                      super.onScrolled(recyclerView, dx, dy);
  
                      totalItemCount = linearLayoutManager.getItemCount();
                      lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
                      if (!loading &amp;&amp; totalItemCount &lt;= (lastVisibleItem + visibleThreshold)) {
                          // End has been reached
                          // Do something
                          Log.i("newsAdaptertest", "onScrolled: End reached");
                          if (onLoadMoreListener != null) {
                              onLoadMoreListener.onLoadMore();
                          }
                          loading = true;
                      }
                  }
              });
          }
  
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder {
          ExpandableTextView postMessage;
          TextView postTitle;
          TextView postSubTitle;
          ImageView authorImage;
  
          public MyViewHolder(View itemView) {
              super(itemView);
              this.authorImage = (ImageView) itemView.findViewById(R.id.header_image);
              this.postTitle = (TextView) itemView.findViewById(R.id.header_title);
              this.postSubTitle = (TextView) itemView.findViewById(R.id.header_subtitle);
              this.postMessage = (ExpandableTextView) itemView.findViewById(R.id.post_text_expand);
          }
      }
  
      @Override
      public int getItemCount() {
          return dataSet.size();
      }
  
      @Override
      public int getItemViewType(int position) {
          return dataSet.get(position) != null ? VIEW_ITEM : VIEW_PROG;
      }
  
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          RecyclerView.ViewHolder vh;
          if (viewType == VIEW_ITEM) {
              View v = LayoutInflater.from(parent.getContext())
                      .inflate(R.layout.recycler_news, parent, false);
  
              vh = new MyViewHolder(v);
          } else {
              View v = LayoutInflater.from(parent.getContext())
                      .inflate(R.layout.recycler_progress, parent, false);
  
              vh = new ProgressViewHolder(v);
          }
          return vh;
      }
  
      @Override
      public void onBindViewHolder(RecyclerView.ViewHolder holder, int listPosition) {
          if (holder instanceof MyViewHolder) {
              Binding Views...
          } else {
              ((ProgressViewHolder) holder).progressBar.setIndeterminate(true);
          }
      }
  
      public void setLoaded() {
          loading = false;
      }
  
      public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
          this.onLoadMoreListener = onLoadMoreListener;
      }
  
      public interface OnLoadMoreListener {
          void onLoadMore();
      }
  
      public static class ProgressViewHolder extends RecyclerView.ViewHolder {
          public ProgressBar progressBar;
  
          public ProgressViewHolder(View v) {
              super(v);
              progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
          }
      }
  
  }
  </code></pre>
  
  <p>And my Activity:</p>
  
  <pre><code>private static NewsAdapterTest adapter;
      private LinearLayoutManager layoutManager;
      private static RecyclerView recyclerView;
      private ArrayList&lt;NewsDataModel&gt; data = new ArrayList&lt;NewsDataModel&gt;();
  
  recyclerView = (RecyclerView) findViewById(R.id.recyclerview_news);
          layoutManager = new LinearLayoutManager(this);
          adapter = new NewsAdapterTest(data, NewsActivity.this, recyclerView);
  
          recyclerView.setHasFixedSize(false);
          recyclerView.setLayoutManager(layoutManager);
          recyclerView.setItemAnimator(new DefaultItemAnimator());
  
          adapter.setOnLoadMoreListener(new NewsAdapterTest.OnLoadMoreListener() {
              @Override
              public void onLoadMore() {
                  Log.i(TAG, "onLoadMore called");
                  //add progress item
                  data.add(null);
                  adapter.notifyItemInserted(data.size() - 1);
  
                  Log.i(TAG, "Loading new data... (" + Integer.toString(loadNumber) + ") posts");
                  loadPosts(startLoadPosition, loadNumber);
                  startLoadPosition += loadNumber;
  
                  //remove progress item
                  data.remove(data.size() - 1);
                  adapter.notifyItemRemoved(data.size());
                  //add items one by one
  
                  adapter.setLoaded();
                  //or you can add all at once but do not forget to call mAdapter.notifyDataSetChanged();
              }
          });
  </code></pre>