2012-05-31 16:01:50 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
2012-09-19 10:32:01 -07:00
|
|
|
import android.app.Activity;
|
2012-05-31 16:01:50 -07:00
|
|
|
import android.content.ComponentName;
|
2012-07-27 17:53:54 -07:00
|
|
|
import android.content.Context;
|
2012-05-31 16:01:50 -07:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.KeyEvent;
|
2012-09-19 10:32:01 -07:00
|
|
|
import android.view.LayoutInflater;
|
2012-05-31 16:01:50 -07:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.SubMenu;
|
|
|
|
import android.view.View;
|
2012-09-19 10:32:01 -07:00
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.BaseAdapter;
|
2012-05-31 16:01:50 -07:00
|
|
|
import android.widget.LinearLayout;
|
2012-09-19 10:32:01 -07:00
|
|
|
import android.widget.ListView;
|
2012-05-31 16:01:50 -07:00
|
|
|
import android.widget.LinearLayout.LayoutParams;
|
|
|
|
|
2012-07-27 17:53:54 -07:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2012-09-19 10:32:01 -07:00
|
|
|
public class GeckoMenu extends ListView
|
|
|
|
implements Menu,
|
|
|
|
MenuItem.OnMenuItemClickListener,
|
|
|
|
AdapterView.OnItemClickListener,
|
|
|
|
GeckoMenuItem.OnVisibilityChangedListener,
|
|
|
|
GeckoMenuItem.OnShowAsActionChangedListener {
|
2012-05-31 16:01:50 -07:00
|
|
|
private static final String LOGTAG = "GeckoMenu";
|
|
|
|
|
|
|
|
private Context mContext;
|
|
|
|
|
2012-07-17 17:54:54 -07:00
|
|
|
public static interface ActionItemBarPresenter {
|
2012-05-31 16:01:50 -07:00
|
|
|
public void addActionItem(View actionItem);
|
2012-06-02 23:09:55 -07:00
|
|
|
public void removeActionItem(int index);
|
2012-05-31 16:01:50 -07:00
|
|
|
public int getActionItemsCount();
|
|
|
|
}
|
|
|
|
|
2012-09-19 10:35:35 -07:00
|
|
|
protected static final int NO_ID = 0;
|
2012-05-31 16:01:50 -07:00
|
|
|
|
2012-09-19 10:32:01 -07:00
|
|
|
// List of all menu items.
|
2012-05-31 16:01:50 -07:00
|
|
|
private List<GeckoMenuItem> mItems;
|
|
|
|
|
2012-06-02 23:09:55 -07:00
|
|
|
// List of items in action-bar.
|
|
|
|
private List<GeckoMenuItem> mActionItems;
|
2012-05-31 16:01:50 -07:00
|
|
|
|
|
|
|
// Reference to action-items bar in action-bar.
|
|
|
|
private ActionItemBarPresenter mActionItemBarPresenter;
|
|
|
|
|
2012-09-19 10:32:01 -07:00
|
|
|
// Adapter to hold the list of menu items.
|
|
|
|
private MenuItemsAdapter mAdapter;
|
|
|
|
|
|
|
|
// ActionBar to show the menu items as icons.
|
|
|
|
private LinearLayout mActionBar;
|
|
|
|
|
2012-05-31 16:01:50 -07:00
|
|
|
public GeckoMenu(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
mContext = context;
|
|
|
|
|
|
|
|
setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
2012-09-19 10:32:01 -07:00
|
|
|
LayoutParams.FILL_PARENT));
|
|
|
|
|
|
|
|
// Add a header view that acts as an action-bar.
|
|
|
|
mActionBar = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.menu_action_bar, null);
|
|
|
|
|
|
|
|
// Attach an adapter.
|
|
|
|
mAdapter = new MenuItemsAdapter(context);
|
|
|
|
setAdapter(mAdapter);
|
|
|
|
setOnItemClickListener(this);
|
2012-05-31 16:01:50 -07:00
|
|
|
|
|
|
|
mItems = new ArrayList<GeckoMenuItem>();
|
2012-06-02 23:09:55 -07:00
|
|
|
mActionItems = new ArrayList<GeckoMenuItem>();
|
2012-09-19 10:32:01 -07:00
|
|
|
|
|
|
|
mActionItemBarPresenter = new DefaultActionItemBarPresenter(mContext, mActionBar);
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MenuItem add(CharSequence title) {
|
|
|
|
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, NO_ID);
|
|
|
|
menuItem.setTitle(title);
|
|
|
|
addItem(menuItem);
|
|
|
|
return menuItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MenuItem add(int groupId, int itemId, int order, int titleRes) {
|
|
|
|
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, itemId, order);
|
|
|
|
menuItem.setTitle(titleRes);
|
|
|
|
addItem(menuItem);
|
|
|
|
return menuItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MenuItem add(int titleRes) {
|
|
|
|
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, NO_ID);
|
|
|
|
menuItem.setTitle(titleRes);
|
|
|
|
addItem(menuItem);
|
|
|
|
return menuItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MenuItem add(int groupId, int itemId, int order, CharSequence title) {
|
|
|
|
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, itemId, order);
|
|
|
|
menuItem.setTitle(title);
|
|
|
|
addItem(menuItem);
|
|
|
|
return menuItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addItem(GeckoMenuItem menuItem) {
|
2012-09-19 10:37:35 -07:00
|
|
|
menuItem.setMenu(this);
|
2012-05-31 16:01:50 -07:00
|
|
|
menuItem.setOnShowAsActionChangedListener(this);
|
2012-09-19 10:32:01 -07:00
|
|
|
menuItem.setOnVisibilityChangedListener(this);
|
|
|
|
menuItem.setOnMenuItemClickListener(this);
|
|
|
|
mAdapter.addMenuItem(menuItem);
|
2012-05-31 16:01:50 -07:00
|
|
|
mItems.add(menuItem);
|
|
|
|
}
|
|
|
|
|
2012-06-02 23:09:55 -07:00
|
|
|
private void addActionItem(GeckoMenuItem menuItem) {
|
2012-09-19 10:37:35 -07:00
|
|
|
menuItem.setMenu(this);
|
2012-06-02 23:09:55 -07:00
|
|
|
menuItem.setOnShowAsActionChangedListener(this);
|
2012-09-19 10:32:01 -07:00
|
|
|
menuItem.setOnVisibilityChangedListener(null);
|
|
|
|
menuItem.setOnMenuItemClickListener(this);
|
|
|
|
|
|
|
|
if (mActionItems.size() == 0 &&
|
|
|
|
mActionItemBarPresenter instanceof DefaultActionItemBarPresenter) {
|
|
|
|
// Reset the adapter before adding the header view to a list.
|
|
|
|
setAdapter(null);
|
|
|
|
addHeaderView(mActionBar);
|
|
|
|
setAdapter(mAdapter);
|
2012-06-02 23:09:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mActionItems.add(menuItem);
|
2012-05-31 16:01:50 -07:00
|
|
|
mActionItemBarPresenter.addActionItem(menuItem.getLayout());
|
2012-09-19 10:32:01 -07:00
|
|
|
mItems.add(menuItem);
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) {
|
2012-09-19 10:35:35 -07:00
|
|
|
MenuItem menuItem = add(groupId, itemId, order, title);
|
|
|
|
GeckoSubMenu subMenu = new GeckoSubMenu(mContext, null);
|
|
|
|
subMenu.setMenuItem(menuItem);
|
|
|
|
((GeckoMenuItem) menuItem).setSubMenu(subMenu);
|
|
|
|
return subMenu;
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) {
|
2012-09-19 10:35:35 -07:00
|
|
|
MenuItem menuItem = add(groupId, itemId, order, titleRes);
|
|
|
|
GeckoSubMenu subMenu = new GeckoSubMenu(mContext, null);
|
|
|
|
subMenu.setMenuItem(menuItem);
|
|
|
|
((GeckoMenuItem) menuItem).setSubMenu(subMenu);
|
|
|
|
return subMenu;
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SubMenu addSubMenu(CharSequence title) {
|
2012-09-19 10:35:35 -07:00
|
|
|
MenuItem menuItem = add(title);
|
|
|
|
GeckoSubMenu subMenu = new GeckoSubMenu(mContext, null);
|
|
|
|
subMenu.setMenuItem(menuItem);
|
|
|
|
((GeckoMenuItem) menuItem).setSubMenu(subMenu);
|
|
|
|
return subMenu;
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SubMenu addSubMenu(int titleRes) {
|
2012-09-19 10:35:35 -07:00
|
|
|
MenuItem menuItem = add(titleRes);
|
|
|
|
GeckoSubMenu subMenu = new GeckoSubMenu(mContext, null);
|
|
|
|
subMenu.setMenuItem(menuItem);
|
|
|
|
((GeckoMenuItem) menuItem).setSubMenu(subMenu);
|
|
|
|
return subMenu;
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void clear() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void close() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MenuItem findItem(int id) {
|
|
|
|
for (GeckoMenuItem menuItem : mItems) {
|
2012-09-19 10:35:35 -07:00
|
|
|
if (menuItem.getItemId() == id) {
|
2012-05-31 16:01:50 -07:00
|
|
|
return menuItem;
|
2012-09-19 10:35:35 -07:00
|
|
|
} else if (menuItem.hasSubMenu()) {
|
|
|
|
SubMenu subMenu = menuItem.getSubMenu();
|
|
|
|
MenuItem item = subMenu.findItem(id);
|
|
|
|
if (item != null)
|
|
|
|
return item;
|
|
|
|
}
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MenuItem getItem(int index) {
|
|
|
|
if (index < mItems.size())
|
|
|
|
return mItems.get(index);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasVisibleItems() {
|
|
|
|
for (GeckoMenuItem menuItem : mItems) {
|
|
|
|
if (menuItem.isVisible())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isShortcutKey(int keyCode, KeyEvent event) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean performIdentifierAction(int id, int flags) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean performShortcut(int keyCode, KeyEvent event, int flags) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void removeGroup(int groupId) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void removeItem(int id) {
|
2012-09-19 10:32:01 -07:00
|
|
|
GeckoMenuItem item = (GeckoMenuItem) findItem(id);
|
|
|
|
if (item != null) {
|
|
|
|
if (mActionItems.contains(item)) {
|
|
|
|
if (mActionItemBarPresenter != null)
|
|
|
|
mActionItemBarPresenter.removeActionItem(mActionItems.indexOf(item));
|
2012-05-31 16:01:50 -07:00
|
|
|
|
2012-09-19 10:32:01 -07:00
|
|
|
mActionItems.remove(item);
|
|
|
|
mItems.remove(item);
|
|
|
|
|
|
|
|
if (mActionItems.size() == 0 &&
|
|
|
|
mActionItemBarPresenter instanceof DefaultActionItemBarPresenter) {
|
|
|
|
// Reset the adapter before removing the header view from a list.
|
|
|
|
setAdapter(null);
|
|
|
|
removeHeaderView(mActionBar);
|
|
|
|
setAdapter(mAdapter);
|
2012-06-02 23:09:55 -07:00
|
|
|
}
|
2012-05-31 16:01:50 -07:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2012-09-19 10:32:01 -07:00
|
|
|
|
|
|
|
mAdapter.removeMenuItem(item);
|
|
|
|
mItems.remove(item);
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setGroupCheckable(int group, boolean checkable, boolean exclusive) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setGroupEnabled(int group, boolean enabled) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setGroupVisible(int group, boolean visible) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setQwertyMode(boolean isQwerty) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int size() {
|
|
|
|
return mItems.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-02 23:09:55 -07:00
|
|
|
public boolean hasActionItemBar() {
|
|
|
|
return (mActionItemBarPresenter != null);
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
2012-06-02 23:09:55 -07:00
|
|
|
@Override
|
|
|
|
public void onShowAsActionChanged(GeckoMenuItem item, boolean isActionItem) {
|
2012-05-31 16:01:50 -07:00
|
|
|
removeItem(item.getItemId());
|
2012-06-02 23:09:55 -07:00
|
|
|
|
|
|
|
if (isActionItem)
|
|
|
|
addActionItem(item);
|
|
|
|
else
|
|
|
|
addItem(item);
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|
|
|
|
|
2012-09-19 10:32:01 -07:00
|
|
|
@Override
|
|
|
|
public void onVisibilityChanged(GeckoMenuItem item, boolean isVisible) {
|
|
|
|
if (isVisible)
|
|
|
|
mAdapter.addMenuItem(item);
|
|
|
|
else
|
|
|
|
mAdapter.removeMenuItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
position -= getHeaderViewsCount();
|
|
|
|
GeckoMenuItem item = mAdapter.getItem(position);
|
|
|
|
if (item.isEnabled())
|
|
|
|
item.onClick(item.getLayout());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
2012-09-19 10:35:35 -07:00
|
|
|
GeckoApp activity = (GeckoApp) mContext;
|
2012-09-19 10:37:35 -07:00
|
|
|
activity.closeOptionsMenu();
|
2012-09-19 10:35:35 -07:00
|
|
|
|
|
|
|
if (!item.hasSubMenu()) {
|
2012-09-19 10:37:35 -07:00
|
|
|
return activity.onOptionsItemSelected(item);
|
2012-09-19 10:35:35 -07:00
|
|
|
} else {
|
2012-09-19 10:37:35 -07:00
|
|
|
// Show the submenu.
|
2012-09-19 10:35:35 -07:00
|
|
|
GeckoApp.MenuPresenter presenter = activity.getMenuPresenter();
|
|
|
|
presenter.show((GeckoSubMenu) item.getSubMenu());
|
|
|
|
return true;
|
|
|
|
}
|
2012-09-19 10:32:01 -07:00
|
|
|
}
|
|
|
|
|
2012-09-19 10:37:35 -07:00
|
|
|
public boolean onCustomMenuItemClick(MenuItem item, MenuItem.OnMenuItemClickListener listener) {
|
|
|
|
((GeckoApp) mContext).closeOptionsMenu();
|
|
|
|
return listener.onMenuItemClick(item);
|
|
|
|
}
|
|
|
|
|
2012-05-31 16:01:50 -07:00
|
|
|
public void setActionItemBarPresenter(ActionItemBarPresenter presenter) {
|
|
|
|
mActionItemBarPresenter = presenter;
|
|
|
|
}
|
2012-09-19 10:32:01 -07:00
|
|
|
|
|
|
|
// Action Items are added to the header view by default.
|
|
|
|
// URL bar can register itself as a presenter, in case it has a different place to show them.
|
|
|
|
private class DefaultActionItemBarPresenter implements ActionItemBarPresenter {
|
|
|
|
private Context mContext;
|
|
|
|
private LinearLayout mContainer;
|
|
|
|
private List<View> mItems;
|
|
|
|
|
|
|
|
private class Divider extends LinearLayout {
|
|
|
|
public Divider(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
|
|
|
|
setLayoutParams(new LinearLayout.LayoutParams((int) context.getResources().getDisplayMetrics().density,
|
|
|
|
LinearLayout.LayoutParams.FILL_PARENT));
|
|
|
|
setBackgroundColor(0xFFD1D5DA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DefaultActionItemBarPresenter(Context context, LinearLayout container) {
|
|
|
|
mContext = context;
|
|
|
|
mContainer = container;
|
|
|
|
mItems = new ArrayList<View>();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addActionItem(View actionItem) {
|
|
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(actionItem.getLayoutParams());
|
|
|
|
params.weight = 1.0f;
|
|
|
|
actionItem.setLayoutParams(params);
|
|
|
|
|
|
|
|
if (mItems.size() > 0) {
|
|
|
|
Divider divider = new Divider(mContext, null);
|
|
|
|
mContainer.addView(divider);
|
|
|
|
}
|
|
|
|
|
|
|
|
mContainer.addView(actionItem);
|
|
|
|
mItems.add(actionItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void removeActionItem(int index) {
|
|
|
|
// Remove the icon and the vertical divider.
|
|
|
|
mContainer.removeViewAt(index * 2);
|
|
|
|
|
|
|
|
if (index != 0)
|
|
|
|
mContainer.removeViewAt(index * 2 - 1);
|
|
|
|
|
|
|
|
mItems.remove(index);
|
|
|
|
|
|
|
|
if (mItems.size() == 0)
|
|
|
|
mContainer.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getActionItemsCount() {
|
|
|
|
return mItems.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adapter to bind menu items to the list.
|
|
|
|
private class MenuItemsAdapter extends BaseAdapter {
|
|
|
|
private Context mContext;
|
|
|
|
private List<GeckoMenuItem> mItems;
|
|
|
|
|
|
|
|
public MenuItemsAdapter(Context context) {
|
|
|
|
mContext = context;
|
|
|
|
mItems = new ArrayList<GeckoMenuItem>();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
|
|
|
return (mItems == null ? 0 : mItems.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GeckoMenuItem getItem(int position) {
|
|
|
|
return mItems.get(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getItemId(int position) {
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
|
return mItems.get(position).getLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean areAllItemsEnabled() {
|
|
|
|
for (GeckoMenuItem item : mItems) {
|
|
|
|
if (!item.isEnabled())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled(int position) {
|
|
|
|
return getItem(position).isEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addMenuItem(GeckoMenuItem menuItem) {
|
|
|
|
if (mItems.contains(menuItem))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Insert it in proper order.
|
|
|
|
int index = 0;
|
|
|
|
for (GeckoMenuItem item : mItems) {
|
|
|
|
if (item.getOrder() > menuItem.getOrder()) {
|
|
|
|
mItems.add(index, menuItem);
|
|
|
|
notifyDataSetChanged();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the menuItem at the end.
|
|
|
|
mItems.add(menuItem);
|
|
|
|
notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeMenuItem(GeckoMenuItem menuItem) {
|
|
|
|
// Remove it from the list.
|
|
|
|
mItems.remove(menuItem);
|
|
|
|
notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
public GeckoMenuItem getMenuItem(int id) {
|
|
|
|
for (GeckoMenuItem item : mItems) {
|
|
|
|
if (item.getItemId() == id)
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2012-05-31 16:01:50 -07:00
|
|
|
}
|