Search in sources :

Example 1 with ResXMLTree_attribute

use of org.robolectric.res.android.ResourceTypes.ResXMLTree_attribute in project robolectric by robolectric.

the class ResXMLParser method getAttributeValue.

public int getAttributeValue(int idx, Ref<Res_value> outValue) {
    if (mEventCode == START_TAG) {
        ResXMLTree_attrExt tag = new ResXMLTree_attrExt(mTree.mBuffer.buf, mCurExt);
        if (idx < dtohs(tag.attributeCount)) {
            // final ResXMLTree_attribute attr = (ResXMLTree_attribute)
            // (((final int8_t*)tag)
            // + dtohs(tag.attributeStart())
            // + (dtohs(tag.attributeSize())*idx));
            ResXMLTree_attribute attr = tag.attributeAt(idx);
            outValue.set(attr.typedValue);
            if (mTree.mDynamicRefTable != null && mTree.mDynamicRefTable.lookupResourceValue(outValue) != NO_ERROR) {
                return BAD_TYPE;
            }
            return ResourceTypes.Res_value.SIZEOF;
        }
    }
    return BAD_TYPE;
}
Also used : ResXMLTree_attribute(org.robolectric.res.android.ResourceTypes.ResXMLTree_attribute) ResXMLTree_attrExt(org.robolectric.res.android.ResourceTypes.ResXMLTree_attrExt)

Example 2 with ResXMLTree_attribute

use of org.robolectric.res.android.ResourceTypes.ResXMLTree_attribute in project robolectric by robolectric.

the class ResXMLParser method getAttributeData.

public int getAttributeData(int idx) {
    if (mEventCode == START_TAG) {
        ResXMLTree_attrExt tag = new ResXMLTree_attrExt(mTree.mBuffer.buf, mCurExt);
        if (idx < dtohs(tag.attributeCount)) {
            // final ResXMLTree_attribute attr = (ResXMLTree_attribute)
            // (((final int8_t*)tag)
            // + dtohs(tag.attributeStart)
            // + (dtohs(tag.attributeSize)*idx));
            ResXMLTree_attribute attr = tag.attributeAt(idx);
            if (attr.typedValue.dataType != DataType.DYNAMIC_REFERENCE.code() || mTree.mDynamicRefTable == null) {
                return dtohl(attr.typedValue.data);
            }
            final Ref<Integer> data = new Ref<>(dtohl(attr.typedValue.data));
            if (mTree.mDynamicRefTable.lookupResourceId(data) == NO_ERROR) {
                return data.get();
            }
        }
    }
    return 0;
}
Also used : ResXMLTree_attribute(org.robolectric.res.android.ResourceTypes.ResXMLTree_attribute) ResXMLTree_attrExt(org.robolectric.res.android.ResourceTypes.ResXMLTree_attrExt)

Example 3 with ResXMLTree_attribute

use of org.robolectric.res.android.ResourceTypes.ResXMLTree_attribute in project robolectric by robolectric.

the class ResXMLParser method getAttributeDataType.

public int getAttributeDataType(int idx) {
    if (mEventCode == START_TAG) {
        final ResXMLTree_attrExt tag = new ResXMLTree_attrExt(mTree.mBuffer.buf, mCurExt);
        if (idx < dtohs(tag.attributeCount)) {
            // final ResXMLTree_attribute attr = (ResXMLTree_attribute)
            // (((final int8_t*)tag)
            // + dtohs(tag.attributeStart())
            // + (dtohs(tag.attributeSize())*idx));
            ResXMLTree_attribute attr = tag.attributeAt(idx);
            int type = attr.typedValue.dataType;
            if (type != DataType.DYNAMIC_REFERENCE.code()) {
                return type;
            }
            // to regular references at this level, so lie to the caller.
            return DataType.REFERENCE.code();
        }
    }
    return DataType.NULL.code();
}
Also used : ResXMLTree_attribute(org.robolectric.res.android.ResourceTypes.ResXMLTree_attribute) ResXMLTree_attrExt(org.robolectric.res.android.ResourceTypes.ResXMLTree_attrExt)

Aggregations

ResXMLTree_attrExt (org.robolectric.res.android.ResourceTypes.ResXMLTree_attrExt)3 ResXMLTree_attribute (org.robolectric.res.android.ResourceTypes.ResXMLTree_attribute)3