Search in sources :

Example 26 with ResName

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

the class AttributeSetBuilderImpl method parse.

private TypedValue parse(Integer attrId, ResName attrResName, String value, String packageName) {
    AttributeResource attribute = new AttributeResource(attrResName, value, packageName);
    TypedValue outValue = new TypedValue();
    if (attribute.isResourceReference()) {
        ResName resourceReference = attribute.getResourceReference();
        int id = resourceResolver.getIdentifier(resourceReference.name, resourceReference.type, resourceReference.packageName);
        if (id == 0) {
            throw new IllegalArgumentException("couldn't resolve " + attribute);
        }
        outValue.type = Res_value.TYPE_REFERENCE;
        outValue.data = id;
        outValue.resourceId = id;
        outValue.string = "@" + id;
    } else {
        resourceResolver.parseValue(attrId, attrResName, attribute, outValue);
    }
    return outValue;
}
Also used : AttributeResource(org.robolectric.res.AttributeResource) ResName(org.robolectric.res.ResName) TypedValue(android.util.TypedValue)

Aggregations

ResName (org.robolectric.res.ResName)26 AttributeResource (org.robolectric.res.AttributeResource)9 TypedValue (android.util.TypedValue)6 FileTypedResource (org.robolectric.res.FileTypedResource)6 ResourceTable (org.robolectric.res.ResourceTable)6 HiddenApi (org.robolectric.annotation.HiddenApi)4 Implementation (org.robolectric.annotation.Implementation)4 TypedResource (org.robolectric.res.TypedResource)4 SuppressLint (android.annotation.SuppressLint)2 PermissionInfo (android.content.pm.PermissionInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 PermissionItemData (org.robolectric.manifest.PermissionItemData)2 AttrData (org.robolectric.res.AttrData)2 EmptyStyle (org.robolectric.res.EmptyStyle)2 ResType (org.robolectric.res.ResType)2 Style (org.robolectric.res.Style)2 ThemeStyleSet (org.robolectric.res.ThemeStyleSet)2