title: RecyclerView crashes when it gets to end of data
body: <p>I have a <strong>RecyclerView</strong> that gets data from a Firebase database.  When the RecyclerView reaches the end of the data feed the app crashes with following:</p>
  
  <p>Logcat file:</p>
  
  <pre><code> 09-27 15:30:12.826 30184-30184/com.pctoolmanconsulting.trackmyweight E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                     Process: com.pctoolmanconsulting.trackmyweight, PID: 30184
                                                                                     java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
                                                                                         at com.pctoolmanconsulting.trackmyweight.ProgressViewHolder.bind(ProgressViewHolder.java:40)
                                                                                         at com.pctoolmanconsulting.trackmyweight.ProgressAdapter.onBindViewHolder(ProgressAdapter.java:41)
                                                                                         at com.pctoolmanconsulting.trackmyweight.ProgressAdapter.onBindViewHolder(ProgressAdapter.java:15)
  </code></pre>
  
  <p>I can not figure out where I am supposed to check for the null value.  In the bind method of my <strong>ViewHolder</strong> class or in the adapter class. </p>
  
  <p>Can someone help point me in the right direction?<br>
  Thanks.</p>
  
  <p><strong>My ViewHolder</strong> bind method:</p>
  
  <pre><code>public void bind (ImageProgress progress){
    name.setText(progress.name);
  
    if(progress.progressDetail.startsWith("https://firebasestorage.googleapis.com/") || progress.progressDetail.startsWith("content://")){
      progressDetailMessage.setVisibility(View.INVISIBLE);
      image.setVisibility(View.VISIBLE);
      Glide.with(activity).load(progress.progressDetail).fitCenter().into(image);
  
    } else {
       progressDetailMessage.setVisibility(View.VISIBLE);
       image.setVisibility(View.GONE);
       progressDetailMessage.setText(progress.progressDetail);
    }
  }
  </code></pre>
  
  <p><strong>adapter class:</strong></p>
  
  <pre><code>public class ProgressAdapter extends RecyclerView.Adapter&lt;ProgressViewHolder&gt; {
  
    private static final String TAG ="ProgressAdapter";
    private final Activity activity;
    List&lt;ImageProgress&gt; progressDetails = new ArrayList&lt;&gt;();
  
    public ProgressAdapter(Activity activity){
      this.activity = activity;
    }
  
    public void addProgress(ImageProgress progress){
      progressDetails.add(progress);
      notifyItemInserted(progressDetails.size());
    }
  
    @Override
    public ProgressViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
      return new ProgressViewHolder(activity, activity.getLayoutInflater().inflate(android.R.layout.two_line_list_item,
              parent, false));
    }
  
    @Override
    public void onBindViewHolder(ProgressViewHolder holder, int position){
      holder.bind(progressDetails.get(position));
    }
  
    @Override
    public int getItemCount() {
      return progressDetails.size();
    }
  }
  </code></pre>