1/* 2 * Copyright (C) 2013 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 18package android.support.v4.view; 19 20import java.lang.reflect.InvocationTargetException; 21import java.lang.reflect.Method; 22 23import android.util.Log; 24import android.view.View; 25import android.view.ViewGroup; 26 27class ViewCompatEclairMr1 { 28 public static final String TAG = "ViewCompat"; 29 30 private static Method sChildrenDrawingOrderMethod; 31 32 public static boolean isOpaque(View view) { 33 return view.isOpaque(); 34 } 35 36 public static void setChildrenDrawingOrderEnabled(ViewGroup viewGroup, boolean enabled) { 37 if (sChildrenDrawingOrderMethod == null) { 38 try { 39 sChildrenDrawingOrderMethod = ViewGroup.class 40 .getDeclaredMethod("setChildrenDrawingOrderEnabled", boolean.class); 41 } catch (NoSuchMethodException e) { 42 Log.e(TAG, "Unable to find childrenDrawingOrderEnabled", e); 43 } 44 sChildrenDrawingOrderMethod.setAccessible(true); 45 } 46 try { 47 sChildrenDrawingOrderMethod.invoke(viewGroup, enabled); 48 } catch (IllegalAccessException e) { 49 Log.e(TAG, "Unable to invoke childrenDrawingOrderEnabled", e); 50 } catch (IllegalArgumentException e) { 51 Log.e(TAG, "Unable to invoke childrenDrawingOrderEnabled", e); 52 } catch (InvocationTargetException e) { 53 Log.e(TAG, "Unable to invoke childrenDrawingOrderEnabled", e); 54 } 55 } 56} 57