Pixelcat-App-Android/app/src/main/kotlin/at/connyduck/pixelcat/components/util/ThemeUtils.kt

16 lines
417 B
Kotlin

package at.connyduck.pixelcat.components.util
import android.content.Context
import android.util.TypedValue
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
@ColorInt
fun Context.getColorForAttr(@AttrRes attr: Int): Int {
val value = TypedValue()
if (theme.resolveAttribute(attr, value, true)) {
return value.data
}
throw IllegalStateException("Attribute not found")
}