title: Facing issue in Position value during Drag and drop in RecyclerView android
body: <p>How do i get new position value during drag and drop in RecyclerView adapter?</p>
  
  <p>Drag and Drop is working perfect but when i set setOnClickListener to open my detail activity. it gives me the old position value.</p>
  
  <p>For example : </p>
  
  <p>If i drag 2nd item (INDEX 1) and drop at 1st item's position (INDEX 0). </p>
  
  <p>On debuging inside setOnClickListener when i am calling Intent. Position value is 1 (INDEX 1) but what i need is value 0 (INDEX 0). </p>
  
  <pre><code> @Override
  public void onBindViewHolder(final ItemViewHolder holder, final int position) {
      holder.textView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(activity, DetailActivity.class);
                  intent.putExtra("NAME_POSITION", position);
                  intent.putParcelableArrayListExtra("NAME_LIST", mName);
                  ((Activity) context).startActivityForResult(intent, 800);
          }
   }
  </code></pre>
  
  <ul>
  <li><p>For Drag and drop i have created 2 Classes. </p>
  
  <p>1) CustomItemTouchHelper extends ItemTouchHelper.Callback</p></li>
  </ul>
  
  <p>class</p>
  
  <pre><code>//Interface interface
  
  public ItemTouchHelper(Interface interface) {
      this.interface = interface;
  }
  
  @Override
  public boolean isLongPressDragEnabled() {
      return true;
  }
  
  @Override
  public boolean isItemViewSwipeEnabled() {
      return false; // swiped disabled
  }
  
  @Override
  public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
      int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // movements drag
      return makeFlag(ItemTouchHelper.ACTION_STATE_DRAG, dragFlags); // as parameter, action drag and flags drag
  }
  
  @Override
  public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
      interface.onMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); // information to the interface
      return true;
  }
  
  @Override
  public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
      // swiped disabled
  }    
  </code></pre>
  
  <p>2) interface for OnMove method</p>
  
  <pre><code>void onMove(int oldPosition, int newPosition);
  </code></pre>
  
  <p>Implemented this method in activity </p>
  
  <pre><code>    ItemTouchHelper.Callback callback = new CustomItemTouchHelper(this);
      ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
      touchHelper.attachToRecyclerView(list);
  </code></pre>
  
  <p>interface implemented in activity.</p>
  
  <pre><code>onMove(int oldPosition, int newPosition) {
    Collections.swap(mNames, oldPosition, newPosition);
    adapter.notifyItemMoved(oldPosition, newPosition);
  }
  </code></pre>
  
  <ul>
  <li>CORRECT or GUIDE me if some thing is missing.</li>
  <li>Thanks &amp; Regards.</li>
  </ul>