Skip to content
This repository has been archived by the owner on Mar 30, 2020. It is now read-only.

Defaults support #17

Merged
merged 5 commits into from
Jul 3, 2015
Merged

Defaults support #17

merged 5 commits into from
Jul 3, 2015

Conversation

ZacSweers
Copy link
Owner

Resolves #16

This allows for the use of a new defaultValue option in StyledAttr annotations, where you can set a resource ID to use as a default.

The generated code will still check Required if the annotation is there. It will not resolve the default value unless there is no resource at that index (that is, it won't unnecessarily resolve it just to pass it into the second param of many of the typedarray getters).

AndroidAttr doesn't support defaults, because it doesn't really make sense to. It would really have to force the user to only use it on setters to be practical.

Fair amount of cleanup/refactoring done in Barbershop as well. This allows for the use of a `defaultValue` option in the StlyedAttr annotation, where you can specify a resource to fall back to.
@ZacSweers
Copy link
Owner Author

Talked with some people, not really going to consider adding defaults support in AndroidAttr unless others request it with some good use cases.

@JakeWharton
Copy link

Usually defaults are set in a style which is either specified as an default theme attr or default style to the typed array creation so I agree 👍

ZacSweers added a commit that referenced this pull request Jul 3, 2015
@ZacSweers ZacSweers merged commit cdd64e6 into master Jul 3, 2015
@ZacSweers ZacSweers deleted the z_defaults branch July 3, 2015 07:44
@ZacSweers
Copy link
Owner Author

Exactly. Yay finally supporting defaults!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default values
2 participants