Merge "Fix bug 5174277 - Trouble with Menus"
This commit is contained in:
@@ -34,6 +34,8 @@ import java.util.ArrayList;
|
||||
* MenuPresenter for list-style menus.
|
||||
*/
|
||||
public class ListMenuPresenter implements MenuPresenter, AdapterView.OnItemClickListener {
|
||||
private static final String TAG = "ListMenuPresenter";
|
||||
|
||||
Context mContext;
|
||||
LayoutInflater mInflater;
|
||||
MenuBuilder mMenu;
|
||||
@@ -76,7 +78,7 @@ public class ListMenuPresenter implements MenuPresenter, AdapterView.OnItemClick
|
||||
public void initForMenu(Context context, MenuBuilder menu) {
|
||||
if (mThemeRes != 0) {
|
||||
mContext = new ContextThemeWrapper(context, mThemeRes);
|
||||
} else if (mContext == null) {
|
||||
} else if (mContext != null) {
|
||||
mContext = context;
|
||||
}
|
||||
mInflater = LayoutInflater.from(mContext);
|
||||
|
||||
@@ -384,7 +384,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
st.menu.stopDispatchingItemsChanged();
|
||||
if ((cb == null) || !cb.onCreatePanelMenu(st.featureId, st.menu)) {
|
||||
// Ditch the menu created above
|
||||
st.menu = null;
|
||||
st.setMenu(null);
|
||||
|
||||
if (mActionBar != null) {
|
||||
// Don't show it in the action bar either
|
||||
@@ -3207,7 +3207,17 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
|
||||
void setMenu(MenuBuilder menu) {
|
||||
if (menu == this.menu) return;
|
||||
|
||||
if (this.menu != null) {
|
||||
this.menu.removeMenuPresenter(iconMenuPresenter);
|
||||
this.menu.removeMenuPresenter(listMenuPresenter);
|
||||
}
|
||||
this.menu = menu;
|
||||
if (menu != null) {
|
||||
if (iconMenuPresenter != null) menu.addMenuPresenter(iconMenuPresenter);
|
||||
if (listMenuPresenter != null) menu.addMenuPresenter(listMenuPresenter);
|
||||
}
|
||||
}
|
||||
|
||||
MenuView getListMenuView(MenuPresenter.Callback cb) {
|
||||
|
||||
Reference in New Issue
Block a user