Search in sources :

Example 1 with EmptyStyle

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

the class ShadowAssetManager 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 * ShadowAssetManager.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 * ShadowAssetManager.STYLE_NUM_ENTRIES;
        TypedValue typedValue = buildTypedValue(set, attrs[i], defStyleAttr, themeStyleSet, defStyleRes);
        if (typedValue != null) {
            //noinspection PointlessArithmeticExpression
            data[offset + ShadowAssetManager.STYLE_TYPE] = typedValue.type;
            data[offset + ShadowAssetManager.STYLE_DATA] = typedValue.type == TypedValue.TYPE_STRING ? i : typedValue.data;
            data[offset + ShadowAssetManager.STYLE_ASSET_COOKIE] = typedValue.assetCookie;
            data[offset + ShadowAssetManager.STYLE_RESOURCE_ID] = typedValue.resourceId;
            data[offset + ShadowAssetManager.STYLE_CHANGING_CONFIGURATIONS] = typedValue.changingConfigurations;
            data[offset + ShadowAssetManager.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) {
        shadowOf(typedArray).positionDescription = set.getPositionDescription();
    }
    return typedArray;
}
Also used : EmptyStyle(org.robolectric.res.EmptyStyle) TypedArray(android.content.res.TypedArray) EmptyStyle(org.robolectric.res.EmptyStyle) Style(org.robolectric.res.Style) TypedValue(android.util.TypedValue)

Aggregations

TypedArray (android.content.res.TypedArray)1 TypedValue (android.util.TypedValue)1 EmptyStyle (org.robolectric.res.EmptyStyle)1 Style (org.robolectric.res.Style)1