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 android.support.design.internal;
18
19import android.content.Context;
20import android.support.annotation.RestrictTo;
21import android.support.v7.view.menu.MenuBuilder;
22import android.view.MenuItem;
23import android.view.SubMenu;
24
25import static android.support.annotation.RestrictTo.Scope.GROUP_ID;
26
27/**
28 * @hide
29 */
30@RestrictTo(GROUP_ID)
31public final class BottomNavigationMenu extends MenuBuilder {
32    public static final int MAX_ITEM_COUNT = 5;
33
34    public BottomNavigationMenu(Context context) {
35        super(context);
36    }
37
38    @Override
39    public SubMenu addSubMenu(int group, int id, int categoryOrder, CharSequence title) {
40        throw new UnsupportedOperationException("BottomNavigationView does not support submenus");
41    }
42
43    @Override
44    protected MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) {
45        if (size() + 1 > MAX_ITEM_COUNT) {
46            throw new IllegalArgumentException(
47                    "Maximum number of items supported by BottomNavigationView is " + MAX_ITEM_COUNT
48                            + ". Limit can be checked with BottomNavigationView#getMaxItemCount()");
49        }
50        return super.addInternal(group, id, categoryOrder, title);
51    }
52}
53