Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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