summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-04-23 18:43:48 (GMT)
committerSunny Goyal <sunnygoyal@google.com>2015-04-23 23:32:10 (GMT)
commitb8c663c492d32963b6ee33750fc985f037c58f10 (patch)
tree015714b7543f671222a6b90d2ac49e4de6560e95
parent3748c5e73107fbfb8bd315653336083578c49026 (diff)
downloadandroid_packages_apps_Trebuchet-b8c663c492d32963b6ee33750fc985f037c58f10.zip
android_packages_apps_Trebuchet-b8c663c492d32963b6ee33750fc985f037c58f10.tar.gz
android_packages_apps_Trebuchet-b8c663c492d32963b6ee33750fc985f037c58f10.tar.bz2
Moving item to its old position in folder if DnD is cancelled
Change-Id: I6362ef23b346409e8517a03e63dee974294a3a18
-rw-r--r--src/com/android/launcher3/Folder.java11
-rw-r--r--src/com/android/launcher3/FolderPagedView.java2
2 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index c35ce94..dff47c2 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -745,9 +745,18 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
replaceFolderWithFinalItem();
}
} else {
- rearrangeChildren();
// The drag failed, we need to return the item to the folder
+ ShortcutInfo info = (ShortcutInfo) d.dragInfo;
+ View icon = (mCurrentDragView != null && mCurrentDragView.getTag() == info)
+ ? mCurrentDragView : mContent.createNewView(info);
+ ArrayList<View> views = getItemsInReadingOrder();
+ views.add(info.rank, icon);
+ mContent.arrangeChildren(views, views.size());
+ mItemsInvalidated = true;
+
+ mSuppressOnAdd = true;
mFolderIcon.onDrop(d);
+ mSuppressOnAdd = false;
}
if (target != this) {
diff --git a/src/com/android/launcher3/FolderPagedView.java b/src/com/android/launcher3/FolderPagedView.java
index 6174892..3f08f43 100644
--- a/src/com/android/launcher3/FolderPagedView.java
+++ b/src/com/android/launcher3/FolderPagedView.java
@@ -363,7 +363,7 @@ public class FolderPagedView extends PagedView {
}
@SuppressLint("InflateParams")
- private View createNewView(ShortcutInfo item) {
+ public View createNewView(ShortcutInfo item) {
final BubbleTextView textView = (BubbleTextView) mInflater.inflate(
R.layout.folder_application, null, false);
textView.applyFromShortcutInfo(item, mIconCache, false);