mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
refactor: Remove BuildCompat calls
This commit is contained in:
parent
d808a48529
commit
ba2b918ebc
@ -1,9 +1,8 @@
|
||||
package com.github.libretube.extensions
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.core.os.BuildCompat
|
||||
import androidx.core.os.BundleCompat
|
||||
import java.io.Serializable
|
||||
|
||||
@ -11,9 +10,8 @@ inline fun <reified T : Parcelable> Bundle.parcelable(key: String?): T? {
|
||||
return BundleCompat.getParcelable(this, key, T::class.java)
|
||||
}
|
||||
|
||||
@OptIn(BuildCompat.PrereleaseSdkCheck::class)
|
||||
inline fun <reified T : Serializable> Bundle.serializable(key: String): T? {
|
||||
return if (BuildCompat.isAtLeastU()) {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
getSerializable(key, T::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
|
@ -1,19 +1,17 @@
|
||||
package com.github.libretube.extensions
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.core.content.IntentCompat
|
||||
import androidx.core.os.BuildCompat
|
||||
import java.io.Serializable
|
||||
|
||||
inline fun <reified T : Parcelable> Intent.parcelableExtra(name: String?): T? {
|
||||
return IntentCompat.getParcelableExtra(this, name, T::class.java)
|
||||
}
|
||||
|
||||
@OptIn(BuildCompat.PrereleaseSdkCheck::class)
|
||||
inline fun <reified T : Serializable> Intent.serializableExtra(name: String?): T? {
|
||||
return if (BuildCompat.isAtLeastU()) {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
getSerializableExtra(name, T::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
|
Loading…
Reference in New Issue
Block a user