About @Parcelize. If I understood correctly, Kotli...
# android
m
About @Parcelize. If I understood correctly, Kotlin compiler can implement Parcelable in existing class. But what about parcelable wrapper, e. g.
class ParcelSomething(val something: Something) : Parcelable {...
, where
Something
is not parcelable itself?
d
There is something for a
CustomParceler
annotation in the KEEP, but it doesn't look like it's been implemented [yet]: https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md#per-property-and-per-type-parcelers
m
'Custom' means 'hand-written', isn't it?
d
What would the alternative to hand-written be? EDIT: Oh I see what you mean. No, the compiler can't implement
Parcelable
on arbitrary existing classes. It can only do so for your own classes annotated with
@Parcelize
.
Also, you could implement a
Parceler
in your companion object if you only need to parcel the whole class and not define them generally on a per-type basis: https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md#custom-parcelables