ViewUtils.java revision 50dfc33a565c4aefe6d5e844c93aa24a74cb80b3
1/* 2 * Copyright (C) 2015 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.design.widget; 18 19import android.os.Build; 20import android.view.View; 21 22class ViewUtils { 23 24 private interface ViewUtilsImpl { 25 void setBoundsViewOutlineProvider(View view); 26 } 27 28 private static class ViewUtilsImplBase implements ViewUtilsImpl { 29 @Override 30 public void setBoundsViewOutlineProvider(View view) { 31 // no-op 32 } 33 } 34 35 private static class ViewUtilsImplLollipop implements ViewUtilsImpl { 36 @Override 37 public void setBoundsViewOutlineProvider(View view) { 38 ViewUtilsLollipop.setBoundsViewOutlineProvider(view); 39 } 40 } 41 42 private static final ViewUtilsImpl IMPL; 43 44 static { 45 final int version = Build.VERSION.SDK_INT; 46 if (version >= 21) { 47 IMPL = new ViewUtilsImplLollipop(); 48 } else { 49 IMPL = new ViewUtilsImplBase(); 50 } 51 } 52 53 static void setBoundsViewOutlineProvider(View view) { 54 IMPL.setBoundsViewOutlineProvider(view); 55 } 56 57} 58