use of org.robolectric.res.Style in project robolectric by robolectric.
the class ShadowLegacyAssetManager method attrsToTypedArray.
TypedArray attrsToTypedArray(Resources resources, AttributeSet set, int[] attrs, int defStyleAttr, long nativeTheme, int defStyleRes) {
CharSequence[] stringData = new CharSequence[attrs.length];
int[] data = new int[attrs.length * STYLE_NUM_ENTRIES];
int[] indices = new int[attrs.length + 1];
int nextIndex = 0;
Style themeStyleSet = nativeTheme == 0 ? new EmptyStyle() : getNativeTheme(nativeTheme).themeStyleSet;
for (int i = 0; i < attrs.length; i++) {
int offset = i * STYLE_NUM_ENTRIES;
TypedValue typedValue = buildTypedValue(set, attrs[i], defStyleAttr, themeStyleSet, defStyleRes);
if (typedValue != null) {
// noinspection PointlessArithmeticExpression
data[offset + STYLE_TYPE] = typedValue.type;
data[offset + STYLE_DATA] = typedValue.type == TypedValue.TYPE_STRING ? i : typedValue.data;
data[offset + STYLE_ASSET_COOKIE] = typedValue.assetCookie;
data[offset + STYLE_RESOURCE_ID] = typedValue.resourceId;
data[offset + STYLE_CHANGING_CONFIGURATIONS] = typedValue.changingConfigurations;
data[offset + STYLE_DENSITY] = typedValue.density;
stringData[i] = typedValue.string;
indices[nextIndex + 1] = i;
nextIndex++;
}
}
indices[0] = nextIndex;
TypedArray typedArray = ShadowTypedArray.create(resources, attrs, data, indices, nextIndex, stringData);
if (set != null) {
ShadowTypedArray shadowTypedArray = Shadow.extract(typedArray);
shadowTypedArray.positionDescription = set.getPositionDescription();
}
return typedArray;
}
Aggregations