title: How to start dragging an item in a RecyclerView by other than long press?
body: <p>My Android App has several RecyclerViews whose items need to be rearrangeable by the user. Every item contains a 'reorder control' which, when pressed, must start the drag of that item. (Comparable to the 'reorder item' in an iOS table view cell). The drag should not be started by a long press. My App uses data binding.</p>
  
  <p>I found several examples in which the ItemTouchHelper is used to enable drag &amp; drop in a RecyclerView. All these examples use the standard long press to start dragging. The code below shows the BindingAdapter to enable drag &amp; drop as it is used in most examples:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @BindingAdapter(value = {"draggable"})
      public static void bindRecyclerViewDraggable(RecyclerView recyclerView, boolean draggable) {
  
          ItemTouchHelper helper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.DOWN | ItemTouchHelper.UP, 0) {
              @Override
              public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder dragged, @NonNull RecyclerView.ViewHolder target) {
  
                  int draggedPos = dragged.getAdapterPosition();
                  int targetPos = target.getAdapterPosition();
  
                  recyclerView.getAdapter().notifyItemMoved(draggedPos, targetPos);
  
                  return true;
              }
  
              @Override
              public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
  
              }
          });
  
          helper.attachToRecyclerView(recyclerView);
      }
  </code></pre>
  
  <p>This method works fine in case long press is used to trigger the drag, but how to trigger the drag when the 'reorder control' is pressed on an item?</p>
  
  <p>One solution I see is that I instantiate the ItemTouchHelper in the ViewModel that is associated with the View that contains the RecyclerView and then attach that to the RecyclerView through data binding. However, that does not feel right in some way. The ItemTouchHelper is a View class (it extends RecyclerView.ItemDecoration) and I want as little as possible View related stuff in my ViewModel.</p>
  
  <p>Can anyone think of a better solution to solve this problem?</p>