2023-06-17 07:57:56 +05:30
|
|
|
package com.github.libretube.extensions
|
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.os.Parcelable
|
2023-09-04 04:52:23 +05:30
|
|
|
import androidx.annotation.OptIn
|
|
|
|
import androidx.core.os.BuildCompat
|
2023-06-17 07:57:56 +05:30
|
|
|
import androidx.core.os.BundleCompat
|
2023-09-04 04:52:23 +05:30
|
|
|
import java.io.Serializable
|
2023-06-17 07:57:56 +05:30
|
|
|
|
|
|
|
inline fun <reified T : Parcelable> Bundle.parcelable(key: String?): T? {
|
|
|
|
return BundleCompat.getParcelable(this, key, T::class.java)
|
|
|
|
}
|
2023-09-04 04:52:23 +05:30
|
|
|
|
|
|
|
@OptIn(BuildCompat.PrereleaseSdkCheck::class)
|
|
|
|
inline fun <reified T : Serializable> Bundle.serializable(key: String): T? {
|
|
|
|
return if (BuildCompat.isAtLeastU()) {
|
|
|
|
getSerializable(key, T::class.java)
|
|
|
|
} else {
|
|
|
|
@Suppress("DEPRECATION")
|
|
|
|
getSerializable(key) as? T
|
|
|
|
}
|
|
|
|
}
|