diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Bundle.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Bundle.kt index d17233c25..5c6258ea4 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Bundle.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Bundle.kt @@ -9,8 +9,8 @@ import android.os.Parcel import android.os.Parcelable import androidx.core.content.IntentCompat import androidx.core.os.BundleCompat +import androidx.core.os.ParcelCompat import androidx.lifecycle.SavedStateHandle -import org.koitharu.kotatsu.core.model.parcelable.ParcelableMangaTags import java.io.Serializable // https://issuetracker.google.com/issues/240585930 @@ -36,11 +36,11 @@ inline fun Bundle.getSerializableCompat(key: String): } inline fun Parcel.readParcelableCompat(): T? { - return readParcelable(ParcelableMangaTags::class.java.classLoader) as T? + return ParcelCompat.readParcelable(this, T::class.java.classLoader, T::class.java) } inline fun Parcel.readSerializableCompat(): T? { - return readSerializable() as T? + return ParcelCompat.readSerializable(this, T::class.java.classLoader, T::class.java) } inline fun Bundle.requireSerializable(key: String): T { @@ -49,12 +49,6 @@ inline fun Bundle.requireSerializable(key: String): T } } -inline fun Bundle.requireParcelable(key: String): T { - return checkNotNull(getParcelableCompat(key)) { - "Parcelable of type \"${T::class.java.name}\" not found at \"$key\"" - } -} - fun SavedStateHandle.require(key: String): T { return checkNotNull(get(key)) { "Value $key not found in SavedStateHandle or has a wrong type"