Fixing issue 5043360, double haptic feedback

-> Minor code cleanup in Folder.java

Change-Id: I62267078bfdab9f37fdef28448a63760db1fc1fb
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 652c8b0..45730e0 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -101,7 +101,7 @@
     private boolean mDragInProgress = false;
     private boolean mDeleteFolderOnDropCompleted = false;
     private boolean mSuppressFolderDeletion = false;
-    private boolean mItemAddedBackToSelf = false;
+    private boolean mItemAddedBackToSelfViaIcon = false;
 
     private boolean mIsEditingName = false;
     private InputMethodManager mInputMethodManager;
@@ -221,7 +221,7 @@
             mContent.removeView(mCurrentDragView);
             mInfo.remove(mCurrentDragInfo);
             mDragInProgress = true;
-            mItemAddedBackToSelf = false;
+            mItemAddedBackToSelfViaIcon = false;
         }
         return true;
     }
@@ -297,12 +297,6 @@
         mContent.requestLayout();
     }
 
-    void onClose() {
-        DragLayer parent = (DragLayer) getParent();
-        parent.removeView(Folder.this);
-        clearFocus();
-    }
-
     void bind(FolderInfo info) {
         mInfo = info;
         ArrayList<ShortcutInfo> children = info.contents;
@@ -465,7 +459,6 @@
         oa.addListener(new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
-                onClose();
                 onCloseComplete();
                 mState = STATE_SMALL;
             }
@@ -662,7 +655,7 @@
 
     public void onDropCompleted(View target, DragObject d, boolean success) {
         if (success) {
-            if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelf) {
+            if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon) {
                 replaceFolderWithFinalItem();
             }
         } else {
@@ -684,7 +677,7 @@
         }
         mDeleteFolderOnDropCompleted = false;
         mDragInProgress = false;
-        mItemAddedBackToSelf = false;
+        mItemAddedBackToSelfViaIcon = false;
         mCurrentDragInfo = null;
         mCurrentDragView = null;
         mSuppressOnAdd = false;
@@ -692,7 +685,7 @@
 
     public void notifyDrop() {
         if (mDragInProgress) {
-            mItemAddedBackToSelf = true;
+            mItemAddedBackToSelfViaIcon = true;
         }
     }
 
@@ -853,6 +846,10 @@
     }
 
     private void onCloseComplete() {
+        DragLayer parent = (DragLayer) getParent();
+        parent.removeView(Folder.this);
+        clearFocus();
+
         if (mRearrangeOnClose) {
             setupContentForNumItems(getItemCount());
             mRearrangeOnClose = false;
@@ -908,7 +905,8 @@
         } else {
             item = (ShortcutInfo) d.dragInfo;
         }
-        // Dragged from self onto self
+        // Dragged from self onto self, currently this is the only path possible, however
+        // we keep this as a distinct code path.
         if (item == mCurrentDragInfo) {
             ShortcutInfo si = (ShortcutInfo) mCurrentDragView.getTag();
             CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mCurrentDragView.getLayoutParams();
@@ -929,6 +927,8 @@
 
     public void onAdd(ShortcutInfo item) {
         mItemsInvalidated = true;
+        // If the item was dropped onto this open folder, we have done the work associated
+        // with adding the item to the folder, as indicated by mSuppressOnAdd being set
         if (mSuppressOnAdd) return;
         if (!findAndSetEmptyCells(item)) {
             // The current layout is full, can we expand it?
@@ -942,6 +942,8 @@
 
     public void onRemove(ShortcutInfo item) {
         mItemsInvalidated = true;
+        // If this item is being dragged from this open folder, we have already handled
+        // the work associated with removing the item, so we don't have to do anything here.
         if (item == mCurrentDragInfo) return;
         View v = getViewForInfo(item);
         mContent.removeView(v);