Ejemplo 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();
  }
Ejemplo n.º 2
0
 public void onDragExit(DragObject d) {
   // 只有是一个真正的drag拖出才关闭文件夹,比如说,在文件夹上放下dragview不是退出drag
   if (!d.dragComplete) {
     mOnExitAlarm.setOnAlarmListener(mOnExitAlarmListener);
     mOnExitAlarm.setAlarm(ON_EXIT_CLOSE_DELAY);
   }
   mReorderAlarm.cancelAlarm();
 }
Ejemplo n.º 3
0
  /*
   * 拖动结束
   */
  public void onDragOver(DragObject d) {
    float[] r = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, d.dragView, null);
    mTargetCell = mContent.findNearestArea((int) r[0], (int) r[1], 1, 1, mTargetCell);

    if (mTargetCell[0] != mPreviousTargetCell[0] || mTargetCell[1] != mPreviousTargetCell[1]) {
      mReorderAlarm.cancelAlarm();
      mReorderAlarm.setOnAlarmListener(mReorderAlarmListener);
      mReorderAlarm.setAlarm(150);
      mPreviousTargetCell[0] = mTargetCell[0];
      mPreviousTargetCell[1] = mTargetCell[1];
    }
  }
Ejemplo n.º 4
0
 public void onDragEnter(DragObject d) {
   mPreviousTargetCell[0] = -1;
   mPreviousTargetCell[1] = -1;
   mOnExitAlarm.cancelAlarm();
 }