The strange behavior of drag&drop using ItemTouchHelper and RecyclerView. How to fix?

I'm trying to use RecyclerView with very convenient for my purposes ItemTouchHelper.
All I want is a simple script “drag & drop” and “swipe-to-dismiss”.
Swipe is working correctly, items are removed in the adapter correctly, the animation is also what is happening, but “drag & drop” works very strange. After a long click, the item will not move, although the selection is triggered, and the adapter method is called onItemMove.

Here is a strange behavior in my RecyclerView

And that's what I'm trying to achieve

Here is the code of the presenter, onSelectedChanged and clearView here only for clarity, selecting.


 adapterAddedCities = new AdapterAddedCities();

 ItemTouchHelper.SimpleCallback callback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN ItemTouchHelper.START | ItemTouchHelper.END) {
 public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
 adapterAddedCities.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition());
 return true;

 public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {

 public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
 if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
 AdapterAddedCities.ViewHolder holder = (AdapterAddedCities.ViewHolder) viewHolder;
 super.onSelectedChanged(viewHolder, actionState);

 public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
 AdapterAddedCities.ViewHolder holder = (AdapterAddedCities.ViewHolder) viewHolder;

 itemTouchHelper = new ItemTouchHelper(callback);

Here are a couple of methods of the adapter that changes the data set and notifying RecyclerView of changes.

public void onItemDismiss(int position) {

 public void onItemMove(int fromPosition, int toPosition) {
 CityInfo tmp = citiesData.remove(fromPosition);
 citiesData.add(toPosition > fromPosition ? toPosition - 1 : toPosition, tmp);
 notifyItemMoved(fromPosition, toPosition);

I started the project from
everything works fine, I do not understand what could be the problem.

Maybe I did not consider something c focus on the movable element or de-emphasizing?
June 14th 19 at 21:00
1 answer
June 14th 19 at 21:02
I updated to in the project and it worked perfectly.

Most likely it was a bug in the library, so if you are faced with a similar problem, just obnoviti to the latest version and check how it behaves the RecyclerView.

Find more questions by tags AndroidJava