Skip to content

Commit

Permalink
Make buildAttribute() return TypedValue and rename to buildTypedValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
jongerrish committed Nov 30, 2016
1 parent b5d2a97 commit aa9d7cc
Showing 1 changed file with 16 additions and 12 deletions.
Expand Up @@ -71,13 +71,13 @@ public ShadowAssetManager getShadowAssetManager() {
AssetManager realObject;

private void convertAndFill(AttributeResource attribute, TypedValue outValue, String qualifiers, boolean resolveRefs) {
if (attribute.isNull() || attribute.isEmpty()) {
if (attribute.isNull()) {
outValue.type = TypedValue.TYPE_NULL;
if (attribute.isEmpty()) {
outValue.data = TypedValue.DATA_NULL_EMPTY;
} else {
outValue.data = TypedValue.DATA_NULL_UNDEFINED;
}
outValue.data = TypedValue.DATA_NULL_UNDEFINED;
return;
} else if (attribute.isEmpty()) {
outValue.type = TypedValue.TYPE_NULL;
outValue.data = TypedValue.DATA_NULL_EMPTY;
return;
}

Expand Down Expand Up @@ -575,7 +575,7 @@ public TypedResource resolveResourceValue(TypedResource value, String qualifiers
return resolveResourceValue(value, qualifiers, resName);
}

private AttributeResource buildAttribute(AttributeSet set, int resId, int defStyleAttr, Style themeStyleSet, int defStyleRes) {
private TypedValue buildTypedValue(AttributeSet set, int resId, int defStyleAttr, Style themeStyleSet, int defStyleRes) {
/*
* When determining the final value of a particular attribute, there are four inputs that come into play:
*
Expand Down Expand Up @@ -661,7 +661,13 @@ private AttributeResource buildAttribute(AttributeSet set, int resId, int defSty
}
}

return attribute;
if (attribute == null || attribute.isNull()) {
return null;
} else {
TypedValue typedValue = new TypedValue();
convertAndFill(attribute, typedValue, RuntimeEnvironment.getQualifiers(), true);
return typedValue;
}
}

private void strictError(String message, Object... args) {
Expand All @@ -685,10 +691,8 @@ TypedArray attrsToTypedArray(Resources resources, AttributeSet set, int[] attrs,
for (int i = 0; i < attrs.length; i++) {
int offset = i * ShadowAssetManager.STYLE_NUM_ENTRIES;

AttributeResource attribute = buildAttribute(set, attrs[i], defStyleAttr, themeStyleSet, defStyleRes);
if (attribute != null && !attribute.isNull()) {
TypedValue typedValue = new TypedValue();
convertAndFill(attribute, typedValue, RuntimeEnvironment.getQualifiers(), true);
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;
Expand Down

0 comments on commit aa9d7cc

Please sign in to comment.