Use better Kotlin syntax

From the PR review
This commit is contained in:
litetex 2022-03-06 16:10:42 +01:00
parent 2887e71fa8
commit e6f59612b0
2 changed files with 15 additions and 16 deletions

View file

@ -2,25 +2,24 @@ package org.schabi.newpipe.util
import android.content.Context
import android.graphics.drawable.Drawable
import android.util.TypedValue
import androidx.annotation.AttrRes
/**
* Utility class for resolving [Drawables](Drawable)
*/
class DrawableResolver {
companion object {
@JvmStatic
fun resolveDrawable(context: Context, @AttrRes attrResId: Int): Drawable? {
return androidx.core.content.ContextCompat.getDrawable(
context,
android.util.TypedValue().apply {
context.theme.resolveAttribute(
attrResId,
this,
true
)
}.resourceId
)
}
object DrawableResolver {
@JvmStatic
fun resolveDrawable(context: Context, @AttrRes attrResId: Int): Drawable? {
return androidx.core.content.ContextCompat.getDrawable(
context,
TypedValue().apply {
context.theme.resolveAttribute(
attrResId,
this,
true
)
}.resourceId
)
}
}