1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.deskclock.actionbarmenu; 17 18 import android.view.Menu; 19 import android.view.MenuItem; 20 21 /** 22 * Interface for handling a single menu item in action bar. 23 */ 24 public interface MenuItemController { 25 26 /** 27 * Sets whether or not the controller is enabled. 28 */ 29 void setEnabled(boolean enabled); 30 31 /** 32 * Returns true if the controller is currently enabled. 33 */ 34 boolean isEnabled(); 35 36 /** 37 * Returns the menu item id that the controller is responsible for. 38 */ 39 int getId(); 40 41 /** 42 * Sets the initial state for the menu item. 43 */ 44 void setInitialState(Menu menu); 45 46 /** 47 * Find the menu item this controller cares about, and make it visible. 48 * 49 * @param menu The menu object containing an item that controller can handle. 50 */ 51 void showMenuItem(Menu menu); 52 53 /** 54 * Attempts to handle the click action. 55 * 56 * @param item The menu item being clicked. 57 * @return True if the action is handled by this controller, false otherwise. 58 */ 59 boolean handleMenuItemClick(MenuItem item); 60 } 61