LibreTube/app/src/main/java/com/github/libretube/extensions/Serializable.kt

14 lines
393 B
Kotlin
Raw Normal View History

2022-11-20 20:24:55 +05:30
package com.github.libretube.ui.extensions
import android.os.Build
import android.os.Bundle
import java.io.Serializable
inline fun <reified T : Serializable> Bundle.serializable(key: String): T? = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializable(key, T::class.java)
2022-11-20 21:46:12 +05:30
else -> {
@Suppress("DEPRECATION")
getSerializable(key) as? T
}
2022-11-20 20:24:55 +05:30
}