|
1 | 1 | package com.hoc.flowmvi.core_ui |
2 | 2 |
|
3 | 3 | import android.content.Intent |
4 | | -import android.os.Build |
5 | 4 | import android.os.Bundle |
6 | 5 | import android.os.Parcelable |
| 6 | +import androidx.core.content.IntentCompat |
| 7 | +import androidx.core.os.BundleCompat |
7 | 8 |
|
8 | 9 | /** |
9 | | - * https://stackoverflow.com/a/73311814/11191424 |
| 10 | + * Wrapper around [IntentCompat.getParcelableExtra] for type-safe parcelable retrieval. |
| 11 | + * |
| 12 | + * @see IntentCompat.getParcelableExtra |
10 | 13 | */ |
11 | 14 | inline fun <reified T : Parcelable> Intent.parcelable(key: String): T? = |
12 | | - // TODO: Use `>`, because https://issuetracker.google.com/issues/240585930#comment6 |
13 | | - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) { |
14 | | - getParcelableExtra(key, T::class.java) |
15 | | - } else { |
16 | | - @Suppress("DEPRECATION") |
17 | | - getParcelableExtra(key) |
18 | | - } |
| 15 | + IntentCompat.getParcelableExtra(this, key, T::class.java) |
19 | 16 |
|
20 | 17 | /** |
21 | | - * https://stackoverflow.com/a/73311814/11191424 |
| 18 | + * Wrapper around [BundleCompat.getParcelable] for type-safe parcelable retrieval. |
| 19 | + * |
| 20 | + * @see BundleCompat.getParcelable |
22 | 21 | */ |
23 | 22 | inline fun <reified T : Parcelable> Bundle.parcelable(key: String): T? = |
24 | | - // TODO: Use `>`, because https://issuetracker.google.com/issues/240585930#comment6 |
25 | | - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) { |
26 | | - getParcelable(key, T::class.java) |
27 | | - } else { |
28 | | - @Suppress("DEPRECATION") |
29 | | - getParcelable(key) |
30 | | - } |
| 23 | + BundleCompat.getParcelable(this, key, T::class.java) |
0 commit comments