FileDocCategorySizeDatePackage
Resources_Theme_Delegate.javaAPI DocAndroid 5.1 API5873Thu Mar 12 22:22:44 GMT 2015android.content.res

Resources_Theme_Delegate

public class Resources_Theme_Delegate extends Object
Delegate used to provide new implementation of a select few methods of {@link Resources.Theme} Through the layoutlib_create tool, the original methods of Theme have been replaced by calls to methods of the same name in this delegate class.

Fields Summary
private static final com.android.layoutlib.bridge.impl.DelegateManager
sManager
Constructors Summary
Methods Summary
public static com.android.layoutlib.bridge.impl.DelegateManagergetDelegateManager()


        
        return sManager;
    
static TypedArrayobtainStyledAttributes(Resources thisResources, android.content.res.Resources.Theme thisTheme, int[] attrs)

        boolean changed = setupResources(thisTheme);
        BridgeTypedArray ta = RenderSessionImpl.getCurrentContext().obtainStyledAttributes(attrs);
        ta.setTheme(thisTheme);
        restoreResources(changed);
        return ta;
    
static TypedArrayobtainStyledAttributes(Resources thisResources, android.content.res.Resources.Theme thisTheme, int resid, int[] attrs)

        boolean changed = setupResources(thisTheme);
        BridgeTypedArray ta = RenderSessionImpl.getCurrentContext().obtainStyledAttributes(resid,
                attrs);
        ta.setTheme(thisTheme);
        restoreResources(changed);
        return ta;
    
static TypedArrayobtainStyledAttributes(Resources thisResources, android.content.res.Resources.Theme thisTheme, android.util.AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes)

        boolean changed = setupResources(thisTheme);
        BridgeTypedArray ta = RenderSessionImpl.getCurrentContext().obtainStyledAttributes(set,
                attrs, defStyleAttr, defStyleRes);
        ta.setTheme(thisTheme);
        restoreResources(changed);
        return ta;
    
static booleanresolveAttribute(Resources thisResources, android.content.res.Resources.Theme thisTheme, int resid, android.util.TypedValue outValue, boolean resolveRefs)

        boolean changed = setupResources(thisTheme);
        boolean found =  RenderSessionImpl.getCurrentContext().resolveThemeAttribute(resid,
                outValue, resolveRefs);
        restoreResources(changed);
        return found;
    
static TypedArrayresolveAttributes(Resources thisResources, android.content.res.Resources.Theme thisTheme, int[] values, int[] attrs)

        // FIXME
        return null;
    
private static com.android.ide.common.rendering.api.StyleResourceValueresolveStyle(int nativeResid)

        if (nativeResid == 0) {
            return null;
        }
        BridgeContext context = RenderSessionImpl.getCurrentContext();
        ResourceReference theme = context.resolveId(nativeResid);
        if (theme.isFramework()) {
            return (StyleResourceValue) context.getRenderResources()
                    .getFrameworkResource(ResourceType.STYLE, theme.getName());
        } else {
            return (StyleResourceValue) context.getRenderResources()
                    .getProjectResource(ResourceType.STYLE, theme.getName());
        }
    
private static voidrestoreResources(boolean changed)

        if (changed) {
            RenderSessionImpl.getCurrentContext().getRenderResources().clearStyles();
        }
    
private static booleansetupResources(android.content.res.Resources.Theme thisTheme)

        // Key is a space-separated list of theme ids applied that have been merged into the
        // BridgeContext's theme to make thisTheme.
        String[] appliedStyles = thisTheme.getKey().split(" ");
        boolean changed = false;
        for (String s : appliedStyles) {
            if (s.isEmpty()) {
                continue;
            }
            // See the definition of force parameter in Theme.applyStyle().
            boolean force = false;
            if (s.charAt(s.length() - 1) == '!") {
                force = true;
                s = s.substring(0, s.length() - 1);
            }
            int styleId = Integer.parseInt(s, 16);
            StyleResourceValue style = resolveStyle(styleId);
            if (style != null) {
                RenderSessionImpl.getCurrentContext().getRenderResources().applyStyle(style, force);
                changed = true;
            }

        }
        return changed;