Closed cvb941 closed 1 year ago
In order to provide custom parceler as described in here.
I'd like to create a Parcelable from a data class which has properties that are not Parcelable by default (Kotlin DateTime's Instant).
@Parcelize @TypeParceler<Instant?, InstantParceler>() data class Event( val title: String, val createdAt: Instant? ) : Parcelable object InstantParceler : Parceler<Instant?> { override fun create(parcel: Parcel) = parcel.readLong().takeIf { it >= 0 }?.let { Instant.fromEpochMilliseconds(it) } override fun Instant?.write(parcel: Parcel, flags: Int) { parcel.writeLong(this?.toEpochMilliseconds() ?: -1) } }
Have sent pr with TypeParceler support
will be released in 0.9.0
In order to provide custom parceler as described in here.
I'd like to create a Parcelable from a data class which has properties that are not Parcelable by default (Kotlin DateTime's Instant).