Optimizing open shortcuts container lookep
findviewById does a DFS, inseat only looking at the first level children
Change-Id: Idc028a56648ca026c6022425e3a6e7453fa91986
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 73cd800..0571787 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3128,7 +3128,15 @@
* @return The open shortcuts container, or null if there is none
*/
public DeepShortcutsContainer getOpenShortcutsContainer() {
- return (DeepShortcutsContainer) mDragLayer.findViewById(R.id.deep_shortcuts_container);
+ // Iterate in reverse order. Shortcuts container is added later to the dragLayer,
+ // and will be one of the last views.
+ for (int i = mDragLayer.getChildCount() - 1; i >= 0; i--) {
+ View child = mDragLayer.getChildAt(i);
+ if (child instanceof DeepShortcutsContainer) {
+ return (DeepShortcutsContainer) child;
+ }
+ }
+ return null;
}
@Override