diff options
author | Adam Powell <adamp@google.com> | 2011-07-22 13:39:08 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2011-07-22 13:39:47 -0700 |
commit | 894bf54c0f50dbbaeb737842a89516a3029e233a (patch) | |
tree | 2ebb6c2a0f17dde25e560b2b311478c4938633d3 | |
parent | 423f0ed494d30bbae1a02c059769f0211f1e4d81 (diff) | |
download | frameworks_base-894bf54c0f50dbbaeb737842a89516a3029e233a.zip frameworks_base-894bf54c0f50dbbaeb737842a89516a3029e233a.tar.gz frameworks_base-894bf54c0f50dbbaeb737842a89516a3029e233a.tar.bz2 |
Fix bug 5027071 - Action menu parent consistency
Make sure that action menus can tolerate moving around in the bar.
Change-Id: I2dfb4ea7e647a6c4e84ec78865af6fd858e3f59f
-rw-r--r-- | core/java/com/android/internal/widget/ActionBarView.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java index 8b74f3d..09262e0 100644 --- a/core/java/com/android/internal/widget/ActionBarView.java +++ b/core/java/com/android/internal/widget/ActionBarView.java @@ -286,8 +286,11 @@ public class ActionBarView extends AbsActionBarView { public void setSplitActionBar(boolean splitActionBar) { if (mSplitActionBar != splitActionBar) { if (mMenuView != null) { + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) { + oldParent.removeView(mMenuView); + } if (splitActionBar) { - removeView(mMenuView); if (mSplitView != null) { mSplitView.addView(mMenuView); } @@ -333,7 +336,10 @@ public class ActionBarView extends AbsActionBarView { MenuBuilder builder = (MenuBuilder) menu; mOptionsMenu = builder; if (mMenuView != null) { - removeView(mMenuView); + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) { + oldParent.removeView(mMenuView); + } } if (mActionMenuPresenter == null) { mActionMenuPresenter = new ActionMenuPresenter(); @@ -352,6 +358,10 @@ public class ActionBarView extends AbsActionBarView { builder.addMenuPresenter(mActionMenuPresenter); builder.addMenuPresenter(mExpandedMenuPresenter); menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + final ViewGroup oldParent = (ViewGroup) menuView.getParent(); + if (oldParent != null && oldParent != this) { + oldParent.removeView(menuView); + } addView(menuView, layoutParams); } else { mActionMenuPresenter.setExpandedActionViewsExclusive(false); @@ -366,6 +376,10 @@ public class ActionBarView extends AbsActionBarView { builder.addMenuPresenter(mExpandedMenuPresenter); menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); if (mSplitView != null) { + final ViewGroup oldParent = (ViewGroup) menuView.getParent(); + if (oldParent != null && oldParent != mSplitView) { + oldParent.removeView(menuView); + } mSplitView.addView(menuView, layoutParams); } else { // We'll add this later if we missed it this time. |