public boolean onLongClick(View v) {
    // Return if workspace is locked
    if (mLauncher.getLockWorkspace()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return true;

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
      ShortcutInfo item = (ShortcutInfo) tag;
      if (!v.isInTouchMode()) {
        return false;
      }

      mLauncher.getWorkspace().beginDragShared(v, this);

      mCurrentDragInfo = item;
      mEmptyCell[0] = item.cellX;
      mEmptyCell[1] = item.cellY;
      mCurrentDragView = v;

      mContent.removeView(mCurrentDragView);
      mInfo.remove(mCurrentDragInfo);
      mDragInProgress = true;
      mItemAddedBackToSelfViaIcon = false;
    }
    return true;
  }
예제 #2
0
  public boolean onLongClick(View v) {
    // 返回是否全局拖动被禁止,如果是,则不执行下面的动作
    if (!mLauncher.isDraggingEnabled()) return true;

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
      ShortcutInfo item = (ShortcutInfo) tag;
      if (!v.isInTouchMode()) {
        return false;
      }

      mLauncher.dismissFolderCling(null);

      mLauncher.getWorkspace().onDragStartedWithItem(v);
      mLauncher.getWorkspace().beginDragShared(v, this); // 此处发起拖动
      mIconDrawable = ((TextView) v).getCompoundDrawables()[1];

      mCurrentDragInfo = item;
      mEmptyCell[0] = item.cellX;
      mEmptyCell[1] = item.cellY;
      mCurrentDragView = v;

      mContent.removeView(mCurrentDragView);
      mInfo.remove(mCurrentDragInfo);
      mDragInProgress = true;
      mItemAddedBackToSelfViaIcon = false;
    }
    return true;
  }