content: package androidx.core.view;
  
  import android.graphics.Point;
  import android.view.MotionEvent;
  import android.view.View;
  
  public class DragStartHelper {
      private boolean mDragging;
      private int mLastTouchX;
      private int mLastTouchY;
      private final OnDragStartListener mListener;
      private final View.OnLongClickListener mLongClickListener = new DragStartHelper$$ExternalSyntheticLambda0(this);
      private final View.OnTouchListener mTouchListener = new DragStartHelper$$ExternalSyntheticLambda1(this);
      private final View mView;
  
      public interface OnDragStartListener {
          boolean onDragStart(View view, DragStartHelper dragStartHelper);
      }
  
      public DragStartHelper(View view, OnDragStartListener listener) {
          this.mView = view;
          this.mListener = listener;
      }
  
      public void attach() {
          this.mView.setOnLongClickListener(this.mLongClickListener);
          this.mView.setOnTouchListener(this.mTouchListener);
      }
  
      public void detach() {
          this.mView.setOnLongClickListener((View.OnLongClickListener) null);
          this.mView.setOnTouchListener((View.OnTouchListener) null);
      }
  
      public void getTouchPosition(Point point) {
          point.set(this.mLastTouchX, this.mLastTouchY);
      }
  
      public boolean onLongClick(View v) {
          return this.mListener.onDragStart(v, this);
      }
  
      public boolean onTouch(View v, MotionEvent event) {
          int x = (int) event.getX();
          int y = (int) event.getY();
          switch (event.getAction()) {
              case 0:
                  this.mLastTouchX = x;
                  this.mLastTouchY = y;
                  break;
              case 1:
              case 3:
                  this.mDragging = false;
                  break;
              case 2:
                  if (MotionEventCompat.isFromSource(event, 8194) && (event.getButtonState() & 1) != 0 && !this.mDragging && !(this.mLastTouchX == x && this.mLastTouchY == y)) {
                      this.mLastTouchX = x;
                      this.mLastTouchY = y;
                      boolean onDragStart = this.mListener.onDragStart(v, this);
                      this.mDragging = onDragStart;
                      return onDragStart;
                  }
          }
          return false;
      }
  }
  