예제 #1
0
  @Override
  public boolean onDrop(DragEvent event) {
    if (!mChildCanGetDragEvent) {
      if (findAppropriateDropHandle(event)) {
        Log.i(TAG, "mCurrentDropHandleView is handling drop.");
        return true;
      }
    }

    if (mOnDropDelegate != null) {
      Object data = mOnDropDelegate.generateDropData();
      boolean result = true;
      if (mOnDropDelegate.checkDropDataAcceptable(data, this)) {
        result = mOnDropDelegate.handleDrop(data, this);
        if (result) {
          mOnDropDelegate.onDropSuccess(this);
        } else {
          mOnDropDelegate.onDropFailed(this);
        }
      } else {
        if (mOnDropDelegate.shouldDispathUnacceptableDropToParent(this)) {
          result = super.onDragEvent(event);
        } else {
          // Because a drop could be obscure when it happens on a GridView
          // so we always need to notify the result if it is denied.
          mOnDropDelegate.notifyDropDataDenied(data, this);
          mOnDropDelegate.onDropFailed(this);
        }
      }

      return result;
    }

    return false;
  }