diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 38ebe14d01..aa123f6b26 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2497,6 +2497,7 @@ public class Launcher extends StatefulActivity implements Launche @Override public void bindAllApplications(AppInfo[] apps, int flags) { mAppsView.getAppsStore().setApps(apps, flags); + PopupContainerWithArrow.dismissInvalidPopup(this); } /** @@ -2528,6 +2529,7 @@ public class Launcher extends StatefulActivity implements Launche public void bindWorkspaceItemsChanged(List updated) { if (!updated.isEmpty()) { mWorkspace.updateShortcuts(updated); + PopupContainerWithArrow.dismissInvalidPopup(this); } } @@ -2552,6 +2554,7 @@ public class Launcher extends StatefulActivity implements Launche public void bindWorkspaceComponentsRemoved(final ItemInfoMatcher matcher) { mWorkspace.removeItemsByMatcher(matcher); mDragController.onAppsRemoved(matcher); + PopupContainerWithArrow.dismissInvalidPopup(this); } @Override diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 6d92b8b627..59930ff850 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -599,6 +599,17 @@ public class PopupContainerWithArrow extends Arr } } + /** + * Dismisses the popup if it is no longer valid + */ + public static void dismissInvalidPopup(BaseDraggingActivity activity) { + PopupContainerWithArrow popup = getOpen(activity); + if (popup != null && (!popup.mOriginalIcon.isAttachedToWindow() + || !canShow(popup.mOriginalIcon, (ItemInfo) popup.mOriginalIcon.getTag()))) { + popup.animateClose(); + } + } + /** * Handler to control drag-and-drop for popup items */ diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java index 2b04365ddc..2adf8ce25a 100644 --- a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java @@ -39,6 +39,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupDataProvider; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntArray; @@ -296,6 +297,7 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity @Override public void bindAllApplications(AppInfo[] apps, int flags) { mAppsView.getAppsStore().setApps(apps, flags); + PopupContainerWithArrow.dismissInvalidPopup(this); } public PopupDataProvider getPopupDataProvider() {