1/* 2 * Copyright (C) 2011 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.content.res; 18 19import com.android.layoutlib.bridge.impl.RenderSessionImpl; 20import com.android.tools.layoutlib.annotations.LayoutlibDelegate; 21 22import android.content.res.Resources.NotFoundException; 23import android.content.res.Resources.Theme; 24import android.util.AttributeSet; 25import android.util.TypedValue; 26 27/** 28 * Delegate used to provide new implementation of a select few methods of {@link Resources$Theme} 29 * 30 * Through the layoutlib_create tool, the original methods of Theme have been replaced 31 * by calls to methods of the same name in this delegate class. 32 * 33 */ 34public class Resources_Theme_Delegate { 35 36 @LayoutlibDelegate 37 /*package*/ static TypedArray obtainStyledAttributes( 38 Resources thisResources, Theme thisTheme, 39 int[] attrs) { 40 return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(attrs); 41 } 42 43 @LayoutlibDelegate 44 /*package*/ static TypedArray obtainStyledAttributes( 45 Resources thisResources, Theme thisTheme, 46 int resid, int[] attrs) 47 throws NotFoundException { 48 return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(resid, attrs); 49 } 50 51 @LayoutlibDelegate 52 /*package*/ static TypedArray obtainStyledAttributes( 53 Resources thisResources, Theme thisTheme, 54 AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { 55 return RenderSessionImpl.getCurrentContext().obtainStyledAttributes( 56 set, attrs, defStyleAttr, defStyleRes); 57 } 58 59 @LayoutlibDelegate 60 /*package*/ static boolean resolveAttribute( 61 Resources thisResources, Theme thisTheme, 62 int resid, TypedValue outValue, 63 boolean resolveRefs) { 64 return RenderSessionImpl.getCurrentContext().resolveThemeAttribute( 65 resid, outValue, resolveRefs); 66 } 67} 68