Esempio n. 1
0
  public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete, boolean success) {
    if (success) {
      if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon) {
        replaceFolderWithFinalItem();
      }
    } else {
      // 拖动失败,将item还给folder。这是由Folder向外拖出时调用的
      mFolderIcon.onDrop(d);

      // TODO
      // We're going to trigger a "closeFolder" which may occur before
      // this item has
      // been added back to the folder -- this could cause the folder to
      // be deleted
      if (mOnExitAlarm.alarmPending()) {
        mSuppressFolderDeletion = true;
      }
    }

    if (target != this) {
      if (mOnExitAlarm.alarmPending()) {
        mOnExitAlarm.cancelAlarm();
        completeDragExit();
      }
    }
    mDeleteFolderOnDropCompleted = false;
    mDragInProgress = false;
    mItemAddedBackToSelfViaIcon = false;
    mCurrentDragInfo = null;
    mCurrentDragView = null;
    mSuppressOnAdd = false;

    // 可能要重新排序,保存到数据库中
    updateItemLocationsInDatabase();
  }
Esempio n. 2
0
  public void onDropCompleted(View target, DragObject d, boolean success) {
    if (success) {
      if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon) {
        replaceFolderWithFinalItem();
      }
    } else {
      // The drag failed, we need to return the item to the folder
      mFolderIcon.onDrop(d);

      // We're going to trigger a "closeFolder" which may occur before this item has
      // been added back to the folder -- this could cause the folder to be deleted
      if (mOnExitAlarm.alarmPending()) {
        mSuppressFolderDeletion = true;
      }
    }

    if (target != this) {
      if (mOnExitAlarm.alarmPending()) {
        mOnExitAlarm.cancelAlarm();
        completeDragExit();
      }
    }
    mDeleteFolderOnDropCompleted = false;
    mDragInProgress = false;
    mItemAddedBackToSelfViaIcon = false;
    mCurrentDragInfo = null;
    mCurrentDragView = null;
    mSuppressOnAdd = false;

    // Reordering may have occured, and we need to save the new item locations. We do this once
    // at the end to prevent unnecessary database operations.
    updateItemLocationsInDatabase();
  }
  public void onDropCompleted(
      final View target, final DragObject d, final boolean isFlingToDelete, final boolean success) {
    if (mDeferDropAfterUninstall) {
      Log.d(TAG, "Deferred handling drop because waiting for uninstall.");
      mDeferredAction =
          new Runnable() {
            public void run() {
              onDropCompleted(target, d, isFlingToDelete, success);
              mDeferredAction = null;
            }
          };
      return;
    }

    boolean beingCalledAfterUninstall = mDeferredAction != null;
    boolean successfulDrop = success && (!beingCalledAfterUninstall || mUninstallSuccessful);

    if (successfulDrop) {
      if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) {
        replaceFolderWithFinalItem();
      }
    } else {
      setupContentForNumItems(getItemCount());
      // The drag failed, we need to return the item to the folder
      mFolderIcon.onDrop(d);
    }

    if (target != this) {
      if (mOnExitAlarm.alarmPending()) {
        mOnExitAlarm.cancelAlarm();
        if (!successfulDrop) {
          mSuppressFolderDeletion = true;
        }
        completeDragExit();
      }
    }

    mDeleteFolderOnDropCompleted = false;
    mDragInProgress = false;
    mItemAddedBackToSelfViaIcon = false;
    mCurrentDragInfo = null;
    mCurrentDragView = null;
    mSuppressOnAdd = false;

    // Reordering may have occured, and we need to save the new item locations. We do this once
    // at the end to prevent unnecessary database operations.
    updateItemLocationsInDatabaseBatch();
  }