Home | History | Annotate | Download | only in menu
      1 /*
      2  * Copyright (C) 2012 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 package android.support.v7.internal.view.menu;
     18 
     19 import android.os.Build;
     20 import android.support.v4.internal.view.SupportMenu;
     21 import android.support.v4.internal.view.SupportMenuItem;
     22 import android.support.v4.internal.view.SupportSubMenu;
     23 import android.view.Menu;
     24 import android.view.MenuItem;
     25 
     26 /**
     27  * @hide
     28  */
     29 public final class MenuWrapperFactory {
     30     private MenuWrapperFactory() {
     31     }
     32 
     33     public static Menu createMenuWrapper(android.view.Menu frameworkMenu) {
     34         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     35             return new MenuWrapperICS(frameworkMenu);
     36         }
     37         return frameworkMenu;
     38     }
     39 
     40     public static MenuItem createMenuItemWrapper(android.view.MenuItem frameworkMenuItem) {
     41         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     42             return new MenuItemWrapperJB(frameworkMenuItem);
     43         } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     44             return new MenuItemWrapperICS(frameworkMenuItem);
     45         }
     46         return frameworkMenuItem;
     47     }
     48 
     49     public static SupportMenu createSupportMenuWrapper(android.view.Menu frameworkMenu) {
     50         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     51             return new MenuWrapperICS(frameworkMenu);
     52         }
     53         throw new UnsupportedOperationException();
     54     }
     55 
     56     public static SupportSubMenu createSupportSubMenuWrapper(
     57             android.view.SubMenu frameworkSubMenu) {
     58         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     59             return new SubMenuWrapperICS(frameworkSubMenu);
     60         }
     61         throw new UnsupportedOperationException();
     62     }
     63 
     64     public static SupportMenuItem createSupportMenuItemWrapper(
     65             android.view.MenuItem frameworkMenuItem) {
     66         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     67             return new MenuItemWrapperJB(frameworkMenuItem);
     68         } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     69             return new MenuItemWrapperICS(frameworkMenuItem);
     70         }
     71         throw new UnsupportedOperationException();
     72     }
     73 }
     74