Use better Kotlin syntax

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

View File

@ -75,7 +75,7 @@ import org.schabi.newpipe.local.feed.item.StreamItem
import org.schabi.newpipe.local.feed.service.FeedLoadService import org.schabi.newpipe.local.feed.service.FeedLoadService
import org.schabi.newpipe.local.subscription.SubscriptionManager import org.schabi.newpipe.local.subscription.SubscriptionManager
import org.schabi.newpipe.util.DeviceUtils import org.schabi.newpipe.util.DeviceUtils
import org.schabi.newpipe.util.DrawableResolver.Companion.resolveDrawable import org.schabi.newpipe.util.DrawableResolver.resolveDrawable
import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NavigationHelper import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountStreams import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountStreams

View File

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