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 androidx.appcompat.view.menu;
     18 
     19 import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
     20 
     21 import android.content.Context;
     22 import android.os.Build;
     23 import android.view.Menu;
     24 import android.view.MenuItem;
     25 import android.view.SubMenu;
     26 
     27 import androidx.annotation.RestrictTo;
     28 import androidx.core.internal.view.SupportMenu;
     29 import androidx.core.internal.view.SupportMenuItem;
     30 import androidx.core.internal.view.SupportSubMenu;
     31 
     32 /**
     33  * @hide
     34  */
     35 @RestrictTo(LIBRARY_GROUP)
     36 public final class MenuWrapperFactory {
     37     private MenuWrapperFactory() {
     38     }
     39 
     40     public static Menu wrapSupportMenu(Context context, SupportMenu supportMenu) {
     41         return new MenuWrapperICS(context, supportMenu);
     42     }
     43 
     44     public static MenuItem wrapSupportMenuItem(Context context, SupportMenuItem supportMenuItem) {
     45         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     46             return new MenuItemWrapperJB(context, supportMenuItem);
     47         } else {
     48             return new MenuItemWrapperICS(context, supportMenuItem);
     49         }
     50     }
     51 
     52     public static SubMenu wrapSupportSubMenu(Context context, SupportSubMenu supportSubMenu) {
     53         return new SubMenuWrapperICS(context, supportSubMenu);
     54     }
     55 }
     56