-
-
Notifications
You must be signed in to change notification settings - Fork 358
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 #5535 from Isira-Seneviratne/Simplify-instance-state
Handle LocationStateButton saved state using Bundle
- Loading branch information
Showing
2 changed files
with
43 additions
and
45 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
18 changes: 18 additions & 0 deletions
18
app/src/main/java/de/westnordost/streetcomplete/util/ktx/Bundle.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,18 @@ | ||
package de.westnordost.streetcomplete.util.ktx | ||
|
||
import android.os.Build | ||
import android.os.Bundle | ||
import android.os.Parcelable | ||
import androidx.core.os.BundleCompat | ||
import java.io.Serializable | ||
|
||
inline fun <reified T : Serializable> Bundle.serializable(key: String?): T? = | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { | ||
getSerializable(key, T::class.java) | ||
} else { | ||
@Suppress("DEPRECATION") | ||
getSerializable(key) as? T | ||
} | ||
|
||
inline fun <reified T : Parcelable> Bundle.parcelable(key: String?): T? = | ||
BundleCompat.getParcelable(this, key, T::class.java) |