Skip to content

Instantly share code, notes, and snippets.

@shkschneider
Created May 23, 2019 09:08
Show Gist options
  • Save shkschneider/9aee5db5bc757f0376b301b374ee84c1 to your computer and use it in GitHub Desktop.
Save shkschneider/9aee5db5bc757f0376b301b374ee84c1 to your computer and use it in GitHub Desktop.
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