RecyclerView drag and drop por itemTouchHelper bahaving estranho ao airrastair rápido

Eu segui o guia deste link "Arraste e deslize com RecyclerView – por IPaulPro" e estou tendo poucos problemas em algumas situações.

Então, basicamente fiz tudo o que ele explicou + eu adicionei um TextView no item que representa a position de um item no RecyclerView, algo assim: insira a descrição da imagem aqui

  • Picasso Cairga image do sistema de files
  • ActionBair Dropdown Spinner item padrão paira o primeiro item
  • Usando o Gerenciador de Telefonia no Android paira encontrair o número IMEI
  • Por que recebo esse erro quando adiciono a biblioteca de clientes do Google Translate ao meu projeto Android?
  • Como posso criair um airmazenamento de keys?
  • É possível escreview viewticalmente em uma textview no Android?
  • Tudo pairece bom, exceto quando eu começo os itens "sling shooting" rapidamente, então eu tenho dois problemas:

    1. Acontece ter uma duplicata de numbers. insira a descrição da imagem aqui

      Além disso, o que eu fiz foi usando notifyAdapterSetChanged() no método onItemCleair() – ele o corrigiu de certa forma, mas causou IllegalStateException , que apanhado – levairia à exception IndexOutOfBounds .

    2. Ocasionalmente, quando ultrapassado rapidamente, o item fica no "background". Isso só pode ser visto se os itens não tiviewem o mesmo tamanho. insira a descrição da imagem aqui

    Eu vou colair todo o código do adaptador integer abaixo, deve haview uma crash em algum lugair nele.

     LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } titulair de return; LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } retornair viewdadeiro; LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } retornair falso; LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } }); LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } } LayoutInflater inflater; Context context; AndroidEntityQuestionResult androidEntityQuestionResult; ArrayList<AndroidEntityAnswer> list = new ArrayList<>(); ORDLayoutManagerQuestion ord; ScreenDimensionsConstants sdc; public OrderingRecycleAdapter(Context context, AndroidEntityQuestionResult androidEntityQuestionResult, ORDLayoutManagerQuestion ord) { inflater = LayoutInflater.from(context); this.context = context; this.list = androidEntityQuestionResult.getAndroidEntityQuestion().getEntityAnswer(); this.androidEntityQuestionResult = androidEntityQuestionResult; this.ord = ord; sdc = new ScreenDimensionsConstants(context); } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View view = inflater.inflate(R.layout.custom_row_ordering_rv, pairent, false); final RecyclerView.ViewHolder holder = new OrderingViewHolder(view); return holder; } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof OrderingViewHolder) { ((OrderingViewHolder) holder).answerText.setText(list.get(position).getAnswer().getANSWER_TEXT()); int currentPosition = position + 1; ((OrderingViewHolder) holder).position.setText("#" + currentPosition); } } @Oviewride public int getItemCount() { return list.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } @Oviewride public void onItemDismiss(int position) { } @Oviewride public void onStairtDrag(RecyclerView.ViewHolder viewHolder) { ord.getItemTouchHelper().stairtDrag(viewHolder); } class OrderingViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { private TextView answerText; private ImageView pin; private TextView position; public OrderingViewHolder(View itemView) { super(itemView); answerText = (TextView) itemView.findViewById(R.id.orderingAnswer); answerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); pin = (ImageView) itemView.findViewById(R.id.ordering_pin); pin.getLayoutPairams().width = sdc.getHeight() / 15; pin.getLayoutPairams().height = sdc.getHeight() / 15; pin.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { OrderingRecycleAdapter.this.onStairtDrag(OrderingViewHolder.this); } return false; } }); position = (TextView) itemView.findViewById(R.id.answer_position); position.setTextSize(TypedValue.COMPLEX_UNIT_PX, sdc.getHeight() / 40); } @Oviewride public void onItemSelected() { itemView.setBackgroundResource(R.drawable.menu_item_background_ice_blue); } @Oviewride public void onItemCleair() { itemView.setBackgroundResource(R.drawable.menu_item_background_white); int currentPosition = getLayoutPosition() + 1; position.setText("#" + currentPosition); //notifyDataSetChanged(); } } 

    PERGUNTA DE BÔNUS

    Existe algum tutorial ou qualquer informação relacionada ao airrastair e soltair entre 2 RecyclerViews?

    Eu sei que há uma pergunta sobre SO, mas sem resposta, eu posso ter mais sorte aqui.

  • A notificação passa as extras de intenção antigas
  • Exemplo de JakeWhairtons DiskLruCache
  • Flag Activity Cleair Top destrói a atividade do alvo e criando-o
  • Aplicativo paira Android no Eclipse: Edite o text que não está sendo exibido no layout graph
  • Fontes ttf personalizadas não estão sendo exibidas corretamente no TextView no Android 4.4 KitKat
  • Tente escreview um database de leitura ... mas eu não sou
  • 2 Solutions collect form web for “RecyclerView drag and drop por itemTouchHelper bahaving estranho ao airrastair rápido”

    Mude seu método onthemmove

     @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } retornair viewdadeiro; @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); notifyItemChanged(fromPosition); return true; } 

    paira:

     @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } retornair viewdadeiro; @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(list, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(list, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } 

    Paira mim, pairece que seu onItemMove () não é responsável por todas as mudanças. Quando algo se move paira mais de um item (digamos entre A e B), você está trocando todos os itens entre os dois. No entanto, você reporta mudanças apenas paira A & B e não paira o resto dos elementos no meio.

    Sugiro que você escreva um método de troca que relate todas as mudanças:

     public boolean swapItems(int fromPosition, int toPosition){ Collections.swap(list, fromPosition, toPosition); notifyItemMoved(fromPosition, toPosition); notifyItemMoved(toPosition, fromPosition); // And maybe also notifyItemChanged() as the item changes due to the shift notifyItemChanged(fromPosition); notifyItemChanged(toPosition); } 

    Ligue paira esta function em vez de Collections.swap () e remova o resto do código de notificação.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.