1/*
2 * Copyright (C) 2014 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.v7.widget;
18
19import android.support.v7.internal.app.WindowCallback;
20import android.support.v7.view.ActionMode;
21import android.view.Menu;
22import android.view.MenuItem;
23import android.view.View;
24
25/**
26 * A simple decorator stub for WindowCallback that passes through any calls
27 * to the wrapped instance as a base implementation. Call super.foo() to call into
28 * the wrapped callback for any subclasses.
29 *
30 * @hide for internal use
31 */
32public class WindowCallbackWrapper implements WindowCallback {
33    private WindowCallback mWrapped;
34
35    public WindowCallbackWrapper(WindowCallback wrapped) {
36        if (wrapped == null) {
37            throw new IllegalArgumentException("Window callback may not be null");
38        }
39        mWrapped = wrapped;
40    }
41
42    @Override
43    public boolean onMenuItemSelected(int featureId, MenuItem menuItem) {
44        return mWrapped.onMenuItemSelected(featureId, menuItem);
45    }
46
47    @Override
48    public boolean onCreatePanelMenu(int featureId, Menu menu) {
49        return mWrapped.onCreatePanelMenu(featureId, menu);
50    }
51
52    @Override
53    public boolean onPreparePanel(int featureId, View menuView, Menu menu) {
54        return mWrapped.onPreparePanel(featureId, menuView, menu);
55    }
56
57    @Override
58    public void onPanelClosed(int featureId, Menu menu) {
59        mWrapped.onPanelClosed(featureId, menu);
60    }
61
62    @Override
63    public boolean onMenuOpened(int featureId, Menu menu) {
64        return mWrapped.onMenuOpened(featureId, menu);
65    }
66
67    @Override
68    public ActionMode startActionMode(ActionMode.Callback callback) {
69        return mWrapped.startActionMode(callback);
70    }
71
72    @Override
73    public View onCreatePanelView(int featureId) {
74        return mWrapped.onCreatePanelView(featureId);
75    }
76}
77