Search in sources :

Example 1 with ThemeStyleSet

use of org.robolectric.res.ThemeStyleSet in project robolectric by robolectric.

the class ShadowAssetManager method resolveStyle.

private Style resolveStyle(@NotNull ResName themeStyleName, Style themeStyleSet) {
    TypedResource themeStyleResource = resourceTable.getValue(themeStyleName, RuntimeEnvironment.getQualifiers());
    if (themeStyleResource == null)
        return null;
    StyleData themeStyleData = (StyleData) themeStyleResource.getData();
    if (themeStyleSet == null) {
        themeStyleSet = new ThemeStyleSet();
    }
    return new StyleResolver(resourceTable, shadowOf(AssetManager.getSystem()).getResourceTable(), themeStyleData, themeStyleSet, themeStyleName, RuntimeEnvironment.getQualifiers());
}
Also used : ThemeStyleSet(org.robolectric.res.ThemeStyleSet) FileTypedResource(org.robolectric.res.FileTypedResource) TypedResource(org.robolectric.res.TypedResource) StyleResolver(org.robolectric.res.StyleResolver) StyleData(org.robolectric.res.StyleData)

Example 2 with ThemeStyleSet

use of org.robolectric.res.ThemeStyleSet in project robolectric by robolectric.

the class ShadowAssetManager method getThemeValue.

@HiddenApi
@Implementation(minSdk = LOLLIPOP)
public boolean getThemeValue(long themePtr, int ident, TypedValue outValue, boolean resolveRefs) {
    ResName resName = resourceTable.getResName(ident);
    ThemeStyleSet themeStyleSet = getNativeTheme(themePtr).themeStyleSet;
    AttributeResource attrValue = themeStyleSet.getAttrValue(resName);
    while (attrValue != null && attrValue.isStyleReference()) {
        ResName attrResName = attrValue.getStyleReference();
        if (attrValue.resName.equals(attrResName)) {
            Logger.info("huh... circular reference for %s?", attrResName.getFullyQualifiedName());
            return false;
        }
        attrValue = themeStyleSet.getAttrValue(attrResName);
    }
    if (attrValue != null) {
        convertAndFill(attrValue, outValue, RuntimeEnvironment.getQualifiers(), resolveRefs);
        return true;
    }
    return false;
}
Also used : AttributeResource(org.robolectric.res.AttributeResource) ThemeStyleSet(org.robolectric.res.ThemeStyleSet) ResName(org.robolectric.res.ResName) HiddenApi(org.robolectric.annotation.HiddenApi) Implementation(org.robolectric.annotation.Implementation)

Aggregations

ThemeStyleSet (org.robolectric.res.ThemeStyleSet)2 HiddenApi (org.robolectric.annotation.HiddenApi)1 Implementation (org.robolectric.annotation.Implementation)1 AttributeResource (org.robolectric.res.AttributeResource)1 FileTypedResource (org.robolectric.res.FileTypedResource)1 ResName (org.robolectric.res.ResName)1 StyleData (org.robolectric.res.StyleData)1 StyleResolver (org.robolectric.res.StyleResolver)1 TypedResource (org.robolectric.res.TypedResource)1