Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e7df996

Browse files
Merge pull request #297 from Kotlin-Android-Open-Source/copilot/update-bundle-intent-compat
Refactor parcelable extensions to use BundleCompat and IntentCompat from AndroidX
2 parents 67bbe5a + d3c6eaf commit e7df996

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
package com.hoc.flowmvi.core_ui
22

33
import android.content.Intent
4-
import android.os.Build
54
import android.os.Bundle
65
import android.os.Parcelable
6+
import androidx.core.content.IntentCompat
7+
import androidx.core.os.BundleCompat
78

89
/**
9-
* https://stackoverflow.com/a/73311814/11191424
10+
* Wrapper around [IntentCompat.getParcelableExtra] for type-safe parcelable retrieval.
11+
*
12+
* @see IntentCompat.getParcelableExtra
1013
*/
1114
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)
1916

2017
/**
21-
* https://stackoverflow.com/a/73311814/11191424
18+
* Wrapper around [BundleCompat.getParcelable] for type-safe parcelable retrieval.
19+
*
20+
* @see BundleCompat.getParcelable
2221
*/
2322
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /