Осмелюсь предположить, из-за низкого уровня знаний в этой сфере. Попробую на примере:
Вот класс ViewHolder из RecyclerView.Adpater'а
public class ViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder {
public int index;
public final TextView mServiceTextView;
public final ImageView mServiceHandleView;
public ViewHolder(
@NonNull View itemView) {
super(itemView);
mServiceTextView = itemView.findViewById(R.id.service);
mServiceHandleView = itemView.findViewById(R.id.service_item_handle);
}
public void setData(int index) {
this.index = index;
mServiceTextView.setText(services.get(index).service);
}
При drag'n'drop вызывается следующий код:
public void onItemMove(int fromPosition, int toPosition) {
Collections.swap(services, fromPosition, toPosition);
notifyItemMoved(fromPosition, toPosition);
Т.е. смена элементов, при этом значение index из ViewHolder остается прежним. Проблема при swap, также поменять значение index внутри класса ViewHolder