Program: 171704
Project: 171704
Buggy source:
@Nullable @Override public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_movies_upcoming,container,false);
  mRecyclerView=(RecyclerView)view.findViewById(R.id.recyclerview_upcoming);
  mMovies=new ArrayList<>();
  mMoviesAdapter=new MoviesAdapter(getContext(),mMovies,new MoviesAdapter.OnBindViewHolderListener(){
    @Override public void onBindViewHolder(    MoviesAdapter.MoviesViewHolder holder,    int position){
      holder.movieTitleTextView.setText(mMovies.get(position).getTitle());
      Glide.with(getContext()).load("String_Node_Str" + mMovies.get(position).getPosterPath()).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.movieImageView);
    }
  }
);
  mMoviesAdapter.setLargeViewIntervalEnabled(false);
  mRecyclerView.setAdapter(mMoviesAdapter);
  final GridLayoutManager gridLayoutManager=new GridLayoutManager(getContext(),2);
  mRecyclerView.setLayoutManager(gridLayoutManager);
  mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){
    @Override public void onScrolled(    RecyclerView recyclerView,    int dx,    int dy){
      int visibleItemCount=gridLayoutManager.getChildCount();
      int totalItemCount=gridLayoutManager.getItemCount();
      int firstVisibleItem=gridLayoutManager.findFirstVisibleItemPosition();
      if (loading) {
        if (totalItemCount > previousTotal) {
          loading=false;
          previousTotal=totalItemCount;
        }
      }
      if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
        loadMovies();
        loading=true;
      }
    }
  }
);
  loadMovies();
  return view;
}

Fixed version (ground truth):
@Nullable @Override public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_movies_upcoming,container,false);
  pagesOver=false;
  presentPage=1;
  loading=true;
  previousTotal=0;
  visibleThreshold=5;
  mRecyclerView=(RecyclerView)view.findViewById(R.id.recyclerview_upcoming);
  mMovies=new ArrayList<>();
  mMoviesAdapter=new MoviesAdapter(getContext(),mMovies,new MoviesAdapter.OnBindViewHolderListener(){
    @Override public void onBindViewHolder(    MoviesAdapter.MoviesViewHolder holder,    int position){
      holder.movieTitleTextView.setText(mMovies.get(position).getTitle());
      Glide.with(getContext()).load("String_Node_Str" + mMovies.get(position).getPosterPath()).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.movieImageView);
    }
  }
);
  mMoviesAdapter.setLargeViewIntervalEnabled(false);
  mRecyclerView.setAdapter(mMoviesAdapter);
  final GridLayoutManager gridLayoutManager=new GridLayoutManager(getContext(),2);
  mRecyclerView.setLayoutManager(gridLayoutManager);
  mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){
    @Override public void onScrolled(    RecyclerView recyclerView,    int dx,    int dy){
      int visibleItemCount=gridLayoutManager.getChildCount();
      int totalItemCount=gridLayoutManager.getItemCount();
      int firstVisibleItem=gridLayoutManager.findFirstVisibleItemPosition();
      if (loading) {
        if (totalItemCount > previousTotal) {
          loading=false;
          previousTotal=totalItemCount;
        }
      }
      if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
        loadMovies();
        loading=true;
      }
    }
  }
);
  loadMovies();
  return view;
}