Home | History | Annotate | Download | only in transition
      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 
     17 package androidx.transition;
     18 
     19 import android.os.Build;
     20 import android.view.ViewGroup;
     21 
     22 import androidx.annotation.NonNull;
     23 
     24 /**
     25  * Compatibility utilities for platform features of {@link ViewGroup}.
     26  */
     27 class ViewGroupUtils {
     28 
     29     /**
     30      * Backward-compatible {@link ViewGroup#getOverlay()}.
     31      */
     32     static ViewGroupOverlayImpl getOverlay(@NonNull ViewGroup group) {
     33         if (Build.VERSION.SDK_INT >= 18) {
     34             return new ViewGroupOverlayApi18(group);
     35         }
     36         return ViewGroupOverlayApi14.createFrom(group);
     37     }
     38 
     39     /**
     40      * Provides access to the hidden ViewGroup#suppressLayout method.
     41      */
     42     static void suppressLayout(@NonNull ViewGroup group, boolean suppress) {
     43         if (Build.VERSION.SDK_INT >= 18) {
     44             ViewGroupUtilsApi18.suppressLayout(group, suppress);
     45         } else {
     46             ViewGroupUtilsApi14.suppressLayout(group, suppress);
     47         }
     48     }
     49 
     50     private ViewGroupUtils() {
     51     }
     52 }
     53