Use AndroidX use extension function instead of Kotlin built-in one

The Kotlin built-in `use` extension function applies to `AutoCloseable` only, and throws an error if the object it's being called on is not an `AutoCloseable`. This causes `OnScreenView` to fail to inflate on SDK < 31 as it retrieved the current theme primary color with a `TypedArray`, which only implements `AutoCloseable` since SDK 31 (Android 12).
The AndroidX core library provides a `use` extension function that applies to `TypeArray` instead of `AutoCloseable` so the fix is just a simple import.
This commit is contained in:
lynxnb 2023-04-20 15:47:29 +02:00 committed by Billy Laws
parent cce4b3f89a
commit b7548e51cf
3 changed files with 3 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.LayerDrawable
import android.util.TypedValue
import androidx.core.content.ContextCompat
import androidx.core.content.res.use
import emu.skyline.R
import emu.skyline.input.ButtonId
import kotlin.math.roundToInt

View File

@ -21,6 +21,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.View.OnTouchListener
import androidx.annotation.IntRange
import androidx.core.content.res.use
import emu.skyline.R
import emu.skyline.input.ButtonId
import emu.skyline.input.ButtonState

View File

@ -13,6 +13,7 @@ import android.graphics.Rect
import android.graphics.RectF
import android.graphics.Typeface
import android.os.SystemClock
import androidx.core.content.res.use
import androidx.core.graphics.minus
import emu.skyline.R
import emu.skyline.input.ButtonId