mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: NPE caused by sparseParcelableArray
This commit is contained in:
parent
da4335d885
commit
6513d43f6e
2 changed files with 9 additions and 1 deletions
|
@ -24,4 +24,11 @@ fun <T : Parcelable?> Intent.getSparseParcelableArrayCompat(name: String, clazz:
|
|||
|
||||
@Suppress("DEPRECATION")
|
||||
fun <T : Parcelable?> Bundle.getSparseParcelableArrayCompat(name: String, clazz: Class<T>) =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) getSparseParcelableArray(name, clazz) else getSparseParcelableArray<T>(name)
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) getSparseParcelableArray(
|
||||
name,
|
||||
clazz
|
||||
) else getSparseParcelableArray<T>(name)
|
||||
} catch (npe: NullPointerException) {
|
||||
null
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue