Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

Resources.Theme.resolveAttribute extension #587

Open
romtsn opened this issue Jun 24, 2018 · 0 comments
Open

Resources.Theme.resolveAttribute extension #587

romtsn opened this issue Jun 24, 2018 · 0 comments

Comments

@romtsn
Copy link
Contributor

romtsn commented Jun 24, 2018

To facilitate the retrieving of an attribute from a theme, I'd like to propose the following extension:

inline fun Resources.Theme.resolveAttribute(
    resId: Int,
    resolveRefs: Boolean = true
): TypedValue = TypedValue().apply { resolveAttribute(resId, this, resolveRefs) }

So this will lead to the following change:

// before
val backgroundValue = TypedValue() 
context.theme.resolveAttribute(android.R.attr.selectableItemBackground, outValue, true)

// after
val backgroundValue = context.theme.resolveAttribute(android.R.attr.selectableItemBackground)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant