1/*
2 * Copyright (C) 2016 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
17package com.android.deskclock.actionbarmenu;
18
19import android.view.Menu;
20import android.view.MenuItem;
21
22/**
23 * Interface for handling a single menu item in action bar.
24 */
25public interface MenuItemController {
26
27    /**
28     * Returns the menu item resource id that the controller manages.
29     */
30    int getId();
31
32    /**
33     * Create the menu item.
34     */
35    void onCreateOptionsItem(Menu menu);
36
37    /**
38     * Called immediately before the {@link MenuItem} is shown.
39     *
40     * @param item the {@link MenuItem} created by the controller
41     */
42    void onPrepareOptionsItem(MenuItem item);
43
44    /**
45     * Attempts to handle the click action.
46     *
47     * @param item the {@link MenuItem} that was selected
48     * @return {@code true} if the action is handled by this controller
49     */
50    boolean onOptionsItemSelected(MenuItem item);
51}
52