/**
   * Handles a notification that a selection event took place.
   *
   * @param eventType The type of event that took place.
   * @param posXPix The x coordinate of the selection start handle.
   * @param posYPix The y coordinate of the selection start handle.
   */
  void handleSelectionEvent(int eventType, float posXPix, float posYPix) {
    boolean shouldHandleSelection = false;
    switch (eventType) {
      case SelectionEventType.SELECTION_HANDLES_SHOWN:
        mWasTapGestureDetected = false;
        mSelectionType = SelectionType.LONG_PRESS;
        shouldHandleSelection = true;
        // Since we're showing pins, we don't care if the previous tap was invalid anymore.
        unscheduleInvalidTapNotification();
        break;
      case SelectionEventType.SELECTION_HANDLES_CLEARED:
        mHandler.handleSelectionDismissal();
        resetAllStates();
        break;
      case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED:
        shouldHandleSelection = mShouldHandleSelectionModification;
        break;
      case SelectionEventType.SELECTION_ESTABLISHED:
        mIsSelectionEstablished = true;
        break;
      case SelectionEventType.SELECTION_DISSOLVED:
        mIsSelectionEstablished = false;
        break;
      default:
    }

    if (shouldHandleSelection) {
      ContentViewCore baseContentView = getBaseContentView();
      if (baseContentView != null) {
        String selection = baseContentView.getSelectedText();
        if (selection != null) {
          mX = posXPix;
          mY = posYPix;
          mSelectedText = selection;
          handleSelection(selection, SelectionType.LONG_PRESS);
        }
      }
    }
  }