package com.github.libretube.extensions import android.os.Build import android.os.Bundle import android.os.Parcelable import androidx.core.os.BundleCompat import java.io.Serializable import kotlin.reflect.safeCast inline fun Bundle.parcelable(key: String?): T? { return BundleCompat.getParcelable(this, key, T::class.java) } inline fun Bundle.parcelableArrayList(key: String?): ArrayList? { return BundleCompat.getParcelableArrayList(this, key, T::class.java) } inline fun Bundle.serializable(key: String?): T? { return getSerializable(this, key, T::class.java) } fun getSerializable(bundle: Bundle, key: String?, clazz: Class): T? { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { bundle.getSerializable(key, clazz) } else { @Suppress("DEPRECATION") clazz.kotlin.safeCast(bundle.getSerializable(key)) } }