Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
companion object : Parceler<Task> {
override fun create(parcel: Parcel): Task {
return Task(
//...
parcel.readEnum()
)
}
override fun Task.write(parcel: Parcel, flags: Int) {
with(parcel) {
//...
writeEnum(priority)
}
}
}
inline fun <reified T : Enum<T>> Parcel.readEnum(): T {
return enumValues<T>()[readInt()]
}
inline fun <reified T : Enum<T>> Parcel.writeEnum(t: T) {
writeInt(t.ordinal)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment