Created
May 23, 2019 09:08
-
-
Save shkschneider/9aee5db5bc757f0376b301b374ee84c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private const val ID = "id" | |
private const val NAME = "name" | |
@Parcelize | |
data class User( | |
val id: UUID = UUID.randomUUID(), | |
val name: String? | |
) : Parcelable { | |
fun toBundle() = bundleOf( | |
ID to id, | |
NAME to name | |
) | |
companion object { | |
fun fromBundle(bundle: Bundle) = User( | |
bundle.getSerializable(ID) as UUID, | |
bundle.getString(NAME) as? String | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment