michael@0: /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.util; michael@0: michael@0: import android.view.Menu; michael@0: import android.view.MenuItem; michael@0: michael@0: public class MenuUtils { michael@0: /* michael@0: * This method looks for a menuitem and sets it's visible state, if michael@0: * it exists. michael@0: */ michael@0: public static void safeSetVisible(Menu menu, int id, boolean visible) { michael@0: MenuItem item = menu.findItem(id); michael@0: if (item != null) { michael@0: item.setVisible(visible); michael@0: } michael@0: } michael@0: michael@0: /* michael@0: * This method looks for a menuitem and sets it's enabled state, if michael@0: * it exists. michael@0: */ michael@0: public static void safeSetEnabled(Menu menu, int id, boolean enabled) { michael@0: MenuItem item = menu.findItem(id); michael@0: if (item != null) { michael@0: item.setEnabled(enabled); michael@0: } michael@0: } michael@0: }