We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c2cd74 commit 1d4432dCopy full SHA for 1d4432d
1 file changed
extensionslib/src/main/java/com/omega_r/libs/extensions/context/ResourceExtensions.kt
@@ -38,4 +38,11 @@ inline fun Context.getColorByAttribute(@AttrRes attrInt: Int): Int {
38
@Suppress("NOTHING_TO_INLINE")
39
inline fun Context.getColorDrawableByAttribute(@AttrRes attrInt: Int): ColorDrawable {
40
return ColorDrawable(getColorByAttribute(attrInt))
41
+}
42
+
43
+@Suppress("NOTHING_TO_INLINE")
44
+inline fun Context.getDrawableByAttribute(@AttrRes attrInt: Int): Drawable? {
45
+ return TypedValue().run {
46
+ if (theme.resolveAttribute(attrInt, this, true)) getCompatDrawable(data) else null
47
+ }
48
}
0 commit comments