Recyclerview causes app close when scrolling
<p>I have a recyclerview. It loads when it scrolls. But when I scroll it from top to bottom  continuously, it crashes (or closes) after a while .</p>

<p><strong>Error :</strong> </p>

<pre><code>Cannot scroll to position a LayoutManager set. Call setLayoutManager with a non-null argument.
     E: No adapter attached; skipping layout
     A: art/runtime/indirect_reference_table.cc:76] Check failed: table_mem_map_.get() != nullptr ashmem_create_region failed for 'indirect ref table': Too many open files
     E: Cannot scroll to position a LayoutManager set. Call setLayoutManager with a non-null argument.
     A: art/runtime/indirect_reference_table.cc:76] Check failed: table_mem_map_.get() != nullptr ashmem_create_region failed for 'indirect ref table': Too many open files
</code></pre>

<p><strong>BookSearchResultListAdapter.java</strong></p>

<pre><code>public class BookSearchResultListAdapter extends RecyclerView.Adapter&lt;BookSearchResultListAdapter.ViewHolder&gt; implements View.OnClickListener{

    private ArrayList&lt;ProductModel&gt; productList;
    private Fragment fragment;
    private RecyclerView recyclerView;
    private int position = 0;

    public BookSearchResultListAdapter(Fragment fragment, ArrayList&lt;ProductModel&gt; productList, RecyclerView recyclerView) {
        this.productList = productList;
        this.fragment = fragment;
        this.recyclerView = recyclerView;
    }

    @Override
    public void onClick(View v) {
            int position = recyclerView.getChildLayoutPosition(v);
            ((BookSearchResultAdapterListener)fragment).onProductItemClicked(productList.get(position));
    }


    private void setOnScrollListener() {
        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if(recyclerView.getLayoutManager() != null){
                    LinearLayoutManager lm= (LinearLayoutManager) recyclerView.getLayoutManager();
                    int Lastposition = lm.findLastCompletelyVisibleItemPosition();
                    if(Lastposition == productList.size()-1 &amp;&amp; Lastposition != position){
                        position = lm.findLastCompletelyVisibleItemPosition();
                        ((BookSearchResultAdapterListener)fragment).onListScrolled();
                    }
                }

            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
            }
        });
    }

    public void addCollectionToList(ArrayList&lt;ProductModel&gt; productList){
        this.productList.addAll(productList);
        notifyItemRangeChanged(0, productList.size() - 1);
    }


    public static class ViewHolder extends RecyclerView.ViewHolder {
        // each data item is just a string in this case
        public TextView productName;
        public TextView manufacturerName;
        public TextView publisherName;
        public ImageView image;
        public ImageView isShelvedIcon;

        public ViewHolder(View view) {
            super(view);
        }
    }

    @Override
    public BookSearchResultListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.component_library_product, parent, false);

        ViewHolder holder = new ViewHolder(v);
        holder.productName = (TextView) v.findViewById(R.id.productName);
        holder.manufacturerName = (TextView)v.findViewById(R.id.pageNumber);
        holder.publisherName = (TextView)v.findViewById(R.id.publisherName);
        holder.image = (ImageView)v.findViewById(R.id.productImage);
        holder.isShelvedIcon = (ImageView)v.findViewById(R.id.isShelvedIcon);

        holder.productName.setTypeface(App.MUSEO_300);
        holder.manufacturerName.setTypeface(App.MUSEO_300);
        holder.publisherName.setTypeface(App.MUSEO_300);

        holder.isShelvedIcon.setVisibility(View.GONE);
        v.setOnClickListener(this);
        setOnScrollListener();
        return holder;
    }


    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        final ProductModel productModel = productList.get(position);
        holder.productName.setText(productModel.getName());
        holder.manufacturerName.setText(productModel.getManufacturer());
        holder.publisherName.setText(productModel.getPublisher());

        Picasso.Builder builder = new Picasso.Builder(fragment.getContext());
        Picasso picasso = builder.build();
        picasso.with(fragment.getContext()).load(productModel.getImage()).into(holder.image);
    }

    @Override
    public int getItemCount() {
        return productList.size();
    }

    public interface BookSearchResultAdapterListener {
        void onProductItemClicked(ProductModel productModel);
        void onListScrolled();
    }
}
</code></pre>