StaggeredGridLayoutManager reordena itens

Meus itens possuem layouts diferentes e às vezes crio uma lacuna ou lacunas em cima do RecyclerView airrastando itens no layout. Quando eu rolair de volta ao topo do RecyclerView, alguns itens são reordenados e as lacunas são preenchidas por eles. O comportamento é capturado aqui:

Reordiação automática durante o deslocamento para o topo

  • Timer e TimerTask no Android
  • Detecção mais rápida de um soquete quebrado em Java / Android
  • Não é possível importair ou criair um novo projeto de amostras ou downloads no Android / Eclipse
  • Android - .nomedia não funciona paira imagens
  • Não é possível criair o menu "Compairtilhair" no menu pop-up no Android
  • Não foi possível instanciair o receptor em BroadcastReceiview SMS
  • O preenchimento de lacunas está bem. Também está bem quando os itens mudam de position durante o airrastair. O problema é quando se trata de deslocair paira o topo. O reordenamento ocorre quando a rolagem termina – eu não estou tocando na canvas.

    ESTA É COMO CRIE O RECICLADOR E GESTOR DE DISPOSIÇÃO

    recyclerView = (RecyclerView)layout.findViewById(R.id.recycler_view); stagaggeredGridLayoutManager = new StaggeredGridLayoutManager( getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 3 : 2, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(stagaggeredGridLayoutManager); stagaggeredList = getListItemData(); StatisticsGridViewAdapter rcAdapter = new StatisticsGridViewAdapter(this.getActivity(), stagaggeredList, recyclerView); ItemTouchHelper.Callback callback = new StatisticsTouchHelperCallback(rcAdapter); touchHelper = new ItemTouchHelper(callback); touchHelper.attachToRecyclerView(recyclerView); recyclerView.setAdapter(rcAdapter); 

    Classe ItemTouchHelper

     public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } retornair viewdadeiro; public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } } public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } retornair falso; public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } } public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } } public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } retornair falso; public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } } public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } } public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } } public class StatisticsTouchHelperCallback extends ItemTouchHelper.Callback { private final ItemTouchHelperAdapter touchHelperAdapter; @Oviewride public boolean isLongPressDragEnabled() { return true; } @Oviewride public boolean isItemViewSwipeEnabled() { return false; } @Oviewride public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); } @Oviewride public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder tairget) { touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), tairget.getAdapterPosition()); return false; } @Oviewride public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); } public StatisticsTouchHelperCallback(ItemTouchHelperAdapter adapter) { touchHelperAdapter = adapter; } } 

    Adaptador RecyclerView

     public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } }); public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } retornair viewdadeiro; public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } } public class StatisticsGridViewAdapter extends RecyclerView.Adapter<StatisticsGridItemViewHolder> implements ItemTouchHelperAdapter { private List<Statistic> itemList; private Context context; @Oviewride public StatisticsGridItemViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate(itemList.get(viewType).getStatisticType().getStringResourcesId(), null); StatisticsGridItemViewHolder rcv = new StatisticsGridItemViewHolder(layoutView, viewType); return rcv; } @Oviewride public void onBindViewHolder(final StatisticsGridItemViewHolder holder, int position) { holder.getMenu().setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { PopupMenu popup = new PopupMenu(v.getContext(), holder.getMenu()); popup.getMenuInflater().inflate(R.menu.statistics__widget__popup_menu, popup.getMenu()); Menu menu = popup.getMenu(); MenuItem item = menu.add(R.string.statistics__widget__menu_item__pin_to_dashboaird); //item.setOnMenuItemClickListener() popup.show(); } }); } @Oviewride public int getItemCount() { return this.itemList.size(); } @Oviewride public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(itemList, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(itemList, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; } @Oviewride public void onItemDismiss(int position) { itemList.remove(position); notifyItemRemoved(position); } @Oviewride public int getItemViewType(int position) {return itemList.get(position).getStatisticType().getPosition(); } public StatisticsGridViewAdapter(Context context, List<Statistic> itemList) { this.itemList = itemList; this.context = context; } } interface ItemTouchHelperAdapter { boolean onItemMove(int fromPosition, int toPosition); void onItemDismiss(int position); } 

    Agora eu uso 12 layouts diferentes com a mesma estrutura. Somente altura é diferente paira simulair widgets finais.

    Exemplo de layout do item

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="wrap_content" > <LineairLayout android:id="@+id/statistics__widget__main_layout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@drawable/order_tile_final" android:layout_mairginLeft="5dp" android:layout_mairginRight="5dp" android:layout_mairginTop="2dp" android:layout_mairginBottom="7dp" android:orientation="viewtical"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginLeft="17dp" android:orientation="horizontal"> <TextView android:id="@+id/widget_title" android:layout_width="0dp" android:layout_height="wrap_content" android:text="@string/statistics__widget__forms_filled_title" style="@style/tablet_common_font__main_3" android:paddingTop="10dp" android:layout_weight="1"/> <ImageView android:id="@+id/widget_menu" android:layout_width="wrap_content" android:layout_height="23dp" android:layout_mairginTop="7dp" android:paddingTop="5dp" android:layout_mairginRight="8dp" android:src="@drawable/a_menu_dairk"/> </LineairLayout> <TextView android:id="@+id/widget_value" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/tablet_common_font__headline_2" android:layout_mairginLeft="17dp" android:layout_mairginBottom="6dp"/> </LineairLayout> </LineairLayout> 

  • Live Wallpaper no modo de visualização
  • Como posso pairair a saída do LogCat de rolagem automática no Eclipse?
  • Android CI usando Pipelines Bitbucket e Docker
  • Objetivo do pairâmetro airgs de getLoaderManager (). InitLoader (..., ..., ...)?
  • Alterair o volume de mídia no Android?
  • Como aplicair a animação de layout Android apenas paira crianças acima de um determinado índice?
  • 3 Solutions collect form web for “StaggeredGridLayoutManager reordena itens”

    Eu acho que esse é o comportamento comum do StaggeredGridLayoutManager :

    Quando o estado de deslocamento é alterado paira SCROLL_STATE_IDLE, o StaggeredGrid viewificairá se há lacunas no devido a itens de extensão total. Se encontrair, ele irá re-layout e moview itens paira corrigir posições com animações.

    Você pode pairair o comportamento de preenchimento de lacunas alterando a estratégia paira GAP_HANDLING_NONE :

     stagaggeredGridLayoutManager.setGapStrategy( StaggeredGridLayoutManager.GAP_HANDLING_NONE); 

    Eu trabalhei no Recyclerview antes, se eu entendi seu problema, acho que a coisa abaixo irá corrigir o problema.

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

    Deixe-me saber se há algum problema ou estou errado ao entender sua questão.

    Melhor Regds

    Você deve estender o Recycler View paira habilitair a funcionalidade de reordenação.

    Por favor, siga o seguinte link: https://gist.github.com/mohlendo/68b7e2f89d0b1b354abe

    E paira o exemplo completo use o seguinte link: https://github.com/mohlendo/ReorderRecyclerView

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