Home | History | Annotate | Download | only in view
      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 
     17 
     18 package android.view;
     19 
     20 import android.view.accessibility.AccessibilityEvent;
     21 
     22 import java.util.List;
     23 
     24 /**
     25  * A simple decorator stub for Window.Callback that passes through any calls
     26  * to the wrapped instance as a base implementation. Call super.foo() to call into
     27  * the wrapped callback for any subclasses.
     28  *
     29  * @hide for internal use
     30  */
     31 public class WindowCallbackWrapper implements Window.Callback {
     32     private Window.Callback mWrapped;
     33 
     34     public WindowCallbackWrapper(Window.Callback wrapped) {
     35         if (wrapped == null) {
     36             throw new IllegalArgumentException("Window callback may not be null");
     37         }
     38         mWrapped = wrapped;
     39     }
     40 
     41     @Override
     42     public boolean dispatchKeyEvent(KeyEvent event) {
     43         return mWrapped.dispatchKeyEvent(event);
     44     }
     45 
     46     @Override
     47     public boolean dispatchKeyShortcutEvent(KeyEvent event) {
     48         return mWrapped.dispatchKeyShortcutEvent(event);
     49     }
     50 
     51     @Override
     52     public boolean dispatchTouchEvent(MotionEvent event) {
     53         return mWrapped.dispatchTouchEvent(event);
     54     }
     55 
     56     @Override
     57     public boolean dispatchTrackballEvent(MotionEvent event) {
     58         return mWrapped.dispatchTrackballEvent(event);
     59     }
     60 
     61     @Override
     62     public boolean dispatchGenericMotionEvent(MotionEvent event) {
     63         return mWrapped.dispatchGenericMotionEvent(event);
     64     }
     65 
     66     @Override
     67     public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
     68         return mWrapped.dispatchPopulateAccessibilityEvent(event);
     69     }
     70 
     71     @Override
     72     public View onCreatePanelView(int featureId) {
     73         return mWrapped.onCreatePanelView(featureId);
     74     }
     75 
     76     @Override
     77     public boolean onCreatePanelMenu(int featureId, Menu menu) {
     78         return mWrapped.onCreatePanelMenu(featureId, menu);
     79     }
     80 
     81     @Override
     82     public boolean onPreparePanel(int featureId, View view, Menu menu) {
     83         return mWrapped.onPreparePanel(featureId, view, menu);
     84     }
     85 
     86     @Override
     87     public boolean onMenuOpened(int featureId, Menu menu) {
     88         return mWrapped.onMenuOpened(featureId, menu);
     89     }
     90 
     91     @Override
     92     public boolean onMenuItemSelected(int featureId, MenuItem item) {
     93         return mWrapped.onMenuItemSelected(featureId, item);
     94     }
     95 
     96     @Override
     97     public void onWindowAttributesChanged(WindowManager.LayoutParams attrs) {
     98         mWrapped.onWindowAttributesChanged(attrs);
     99     }
    100 
    101     @Override
    102     public void onContentChanged() {
    103         mWrapped.onContentChanged();
    104     }
    105 
    106     @Override
    107     public void onWindowFocusChanged(boolean hasFocus) {
    108         mWrapped.onWindowFocusChanged(hasFocus);
    109     }
    110 
    111     @Override
    112     public void onAttachedToWindow() {
    113         mWrapped.onAttachedToWindow();
    114     }
    115 
    116     @Override
    117     public void onDetachedFromWindow() {
    118         mWrapped.onDetachedFromWindow();
    119     }
    120 
    121     @Override
    122     public void onPanelClosed(int featureId, Menu menu) {
    123         mWrapped.onPanelClosed(featureId, menu);
    124     }
    125 
    126     @Override
    127     public boolean onSearchRequested(SearchEvent searchEvent) {
    128         return mWrapped.onSearchRequested(searchEvent);
    129     }
    130 
    131     @Override
    132     public boolean onSearchRequested() {
    133         return mWrapped.onSearchRequested();
    134     }
    135 
    136     @Override
    137     public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
    138         return mWrapped.onWindowStartingActionMode(callback);
    139     }
    140 
    141     @Override
    142     public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
    143         return mWrapped.onWindowStartingActionMode(callback, type);
    144     }
    145 
    146     @Override
    147     public void onActionModeStarted(ActionMode mode) {
    148         mWrapped.onActionModeStarted(mode);
    149     }
    150 
    151     @Override
    152     public void onActionModeFinished(ActionMode mode) {
    153         mWrapped.onActionModeFinished(mode);
    154     }
    155 
    156     @Override
    157     public void onProvideKeyboardShortcuts(
    158             List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
    159         mWrapped.onProvideKeyboardShortcuts(data, menu, deviceId);
    160     }
    161 }
    162 
    163