title: RecyclerView, notifyItemRemoved sometimes removed invalid item, notifyDataSetChanged works perfectly
body: <p>I have a RecyclerView with Adapter and ViewHolder classes, so it's 3 classes, I've added a onLongClick in my ViewHolder, when it's long clicked, the selected item will be removed, i'm removing it as the following : </p>
  
  <pre><code>            MyRV.Items.remove(getLayoutPosition());
              MyRV.mAdapter.notifyItemRemoved(getLayoutPosition());
  </code></pre>
  
  <p>Items : </p>
  
  <ol>
  <li>Item_1</li>
  <li>Item_2</li>
  <li>Item_3</li>
  <li>Item_4</li>
  <li><p>Item_5</p>
  
  <pre><code>Removing Item 2 - Item 2 removed .
  Removing Item 3 (which is item 2 now) - Item 1 removed (item - 1) .
  </code></pre></li>
  </ol>
  
  <p>My Data items are about 7 items, So here's what's happening. When first remove, it removes the correct item, when you click on remove again, it removed the above item rather than removing the selected item, and when the size is 1, it FC because invalid size .</p>
  
  <p>My question is similar to this : <a href="https://stackoverflow.com/questions/28189371/using-notifyitemremoved-or-notifydatasetchanged-with-recyclerview-in-android">using notifyItemRemoved or notifyDataSetChanged with RecyclerView in Android</a></p>
  
  <p>But the answers didn't work, none of them, from itemRange to index + 1 .</p>
  
  <pre><code>public class MyAdapterextends RecyclerView.Adapter&lt;MyViewHolder&gt; {
  
  private List&lt;MyItem&gt; itemList;
  public Context context;
  
  public MyAdapter(Context context, List&lt;MyItem&gt; itemList) {
      this.itemList = itemList;
      this.context = context;
  }
  
  @Override
  public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
      View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.myitem, null);
      return new MyViewHolder(layoutView);
  }
  
  
  
  @Override
  public void onBindViewHolder(final MyViewHolder holder, final int position) {
  
      holder.From.setText(itemList.get(holder.getAdapterPosition()).getFrom());
      holder.To.setText(itemList.get(holder.getAdapterPosition()).getTo());
  
  
  }
  
  @Override
  public int getItemCount() {
      return this.itemList.size();
    }
  }
  </code></pre>
  
  <p>Activity </p>
  
  <pre><code>    LinearLayoutManager LinLayout = new LinearLayoutManager(MyActivity.this, LinearLayoutManager.VERTICAL, false);
      mAdapter = new MyAdapter(MyActivity.this, Items);
  
      RcView.setItemAnimator(new ItemAnimator());
      RcView.setHasFixedSize(true);
      RcView.setLayoutManager(LinLayout);
      RcView.setAdapter(mAdapter);
  </code></pre>