Merge "Adding more debug code for dup. ItemInfo bug" into jb-mr1-dev
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index d83fcac..f742255 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -1026,7 +1026,7 @@
super.onSizeChanged(w, h, oldw, oldh);
mBackgroundRect.set(0, 0, w, h);
mForegroundRect.set(mForegroundPadding, mForegroundPadding,
- w - 2 * mForegroundPadding, h - 2 * mForegroundPadding);
+ w - mForegroundPadding, h - mForegroundPadding);
}
@Override
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 2fcf869..ab361f1 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2474,6 +2474,9 @@
alphaAnim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
+ if (animation == null) {
+ throw new RuntimeException("animation is null");
+ }
float t = (Float) animation.getAnimatedValue();
dispatchOnLauncherTransitionStep(fromView, t);
dispatchOnLauncherTransitionStep(toView, t);
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 269a0fd..909cc79 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -2168,6 +2168,24 @@
}
/**
+ * Returns the set of workspace ShortcutInfos with the specified intent.
+ */
+ static ArrayList<ItemInfo> getWorkspaceShortcutItemInfosWithIntent(Intent intent) {
+ ArrayList<ItemInfo> items = new ArrayList<ItemInfo>();
+ synchronized (sBgLock) {
+ for (ItemInfo info : sBgWorkspaceItems) {
+ if (info instanceof ShortcutInfo) {
+ ShortcutInfo shortcut = (ShortcutInfo) info;
+ if (shortcut.intent.toUri(0).equals(intent.toUri(0))) {
+ items.add(shortcut);
+ }
+ }
+ }
+ }
+ return items;
+ }
+
+ /**
* Make an ShortcutInfo object for a shortcut that isn't an application.
*/
private ShortcutInfo getShortcutInfo(Cursor c, Context context,
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 504f9dc..897e95a 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -3697,6 +3697,8 @@
}
// Clean up new-apps animation list
+ final LauncherModel model = mLauncher.getModel();
+ final Context context = getContext();
post(new Runnable() {
@Override
public void run() {
@@ -3717,6 +3719,14 @@
if (packageNames.contains(pn)) {
iter.remove();
}
+
+ // It is possible that we've queued an item to be loaded, yet it has
+ // not been added to the workspace, so remove those items as well.
+ ArrayList<ItemInfo> shortcuts =
+ model.getWorkspaceShortcutItemInfosWithIntent(intent);
+ for (ItemInfo info : shortcuts) {
+ model.deleteItemFromDatabase(context, info);
+ }
} catch (URISyntaxException e) {}
}
}