title: RecyclerView's removed row still gets click events?
body: <p>I have a <code>RecyclerView</code> showing a list of items. The <code>ViewHolder</code> for each rows contains a delete button, to remove the row. If I remove the last row and tap very fast on the disappearing row, I can crash my app because the second tap event is delivered to the removed row. I'm surprised that android delivers the second event. Before I try adding something like <code>boolean isDeleted</code> to my <code>ViewHolder</code> subclass, I'm wondering: am I doing something else wrong to get in this situation?</p>
  
  <pre><code>class MyAdapter extends RecyclerView.Adapter&lt;MyViewHolder&gt; 
                  implements ItemTouchHelperAdapter {
  
      List&lt;Segment&gt; segments;
      MyAdapter(List&lt;Segment&gt; objs) {
          this.segments = objs;
      }
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          LinearLayout v = (LinearLayout) LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.segment_edit_row, parent, false);
          MyViewHolder vh = new MyViewHolder(v);
          return vh;
      }
  
      @Override
      public void onBindViewHolder(MyViewHolder holder, int position) {
          Segment seg = segments.get(position);
          holder.textView.setText(seg.getTitle());
  
          holder.dragHandle.setOnTouchListener((v, event) -&gt; {
              if (MotionEventCompat.getActionMasked(event) ==
                      MotionEvent.ACTION_DOWN) {
                  onStartDrag(holder);
              }
              return false;
          });
          holder.deleteButton.setOnClickListener(v -&gt; {                
              segments.remove(position);
              notifyItemRemoved(position);
          });
  
          View.OnClickListener editExerciseListener = v -&gt; {                
              Segment segment = segments.get(position);
              startEditSegmentActivity(segment, position);
          };
  
          holder.textView.setOnClickListener(editExerciseListener);
          holder.arrow.setOnClickListener(editExerciseListener);
      }
  </code></pre>
  
  <p>The <code>deleteButton</code> handler runs first, and then the <code>editExerciseListener</code>, with the <code>position</code> that is now out of bounds.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Several people have suggested I call <code>notifyDataSetChanged</code>. The Android docs specifically recommend not to do that if you can describe your change with a call to <code>notifyItemRemoved</code> instead.</p>
  
  <p><a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyDataSetChanged()" rel="nofollow noreferrer">https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyDataSetChanged()</a></p>
  
  <p>Are those docs wrong?</p>