-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #527 from hoangchungk53qx1/master
Alternative Parcelable and Serializable are deprecated.
- Loading branch information
Showing
6 changed files
with
51 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
serviceLibrary/src/main/java/info/mqtt/android/service/extension/BundleExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package info.mqtt.android.service.extension | ||
|
||
import android.os.Bundle | ||
import java.io.Serializable | ||
import android.os.Build | ||
import android.os.Build.VERSION.SDK_INT | ||
import android.os.Parcelable | ||
|
||
@Suppress("DEPRECATION") | ||
inline fun <reified T : Parcelable> Bundle.parcelable(key: String): T? = when { | ||
SDK_INT >= 33 -> getParcelable(key, T::class.java) | ||
else -> getParcelable(key) as? T | ||
} | ||
|
||
@Suppress("DEPRECATION") | ||
inline fun <reified T : Serializable> Bundle.serializable(key: String): T? = when { | ||
SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializable(key, T::class.java) | ||
else -> getSerializable(key) as? T | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters