From ba2b918ebcf6012e47c4c1b2b5cf8ec9f52b6747 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Thu, 7 Sep 2023 19:31:59 +0530 Subject: [PATCH] refactor: Remove BuildCompat calls --- app/src/main/java/com/github/libretube/extensions/Bundle.kt | 6 ++---- app/src/main/java/com/github/libretube/extensions/Intent.kt | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/extensions/Bundle.kt b/app/src/main/java/com/github/libretube/extensions/Bundle.kt index 776f79c88..52ca984c2 100644 --- a/app/src/main/java/com/github/libretube/extensions/Bundle.kt +++ b/app/src/main/java/com/github/libretube/extensions/Bundle.kt @@ -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 Bundle.parcelable(key: String?): T? { return BundleCompat.getParcelable(this, key, T::class.java) } -@OptIn(BuildCompat.PrereleaseSdkCheck::class) inline fun 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") diff --git a/app/src/main/java/com/github/libretube/extensions/Intent.kt b/app/src/main/java/com/github/libretube/extensions/Intent.kt index 5118ada14..b2b3011e8 100644 --- a/app/src/main/java/com/github/libretube/extensions/Intent.kt +++ b/app/src/main/java/com/github/libretube/extensions/Intent.kt @@ -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 Intent.parcelableExtra(name: String?): T? { return IntentCompat.getParcelableExtra(this, name, T::class.java) } -@OptIn(BuildCompat.PrereleaseSdkCheck::class) inline fun 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")