martynas
06/27/2018, 6:39 AM@Parcelize
? I have a class where Bar
is 3rd party library class.
data class Foo(
val id : Int = 0,
val bar : Bar? = null
)
At compile time I get Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'
on Bar
.
That is fine by me. I’m happy to lose that value. But no combination of @IgnoredOnParcel
and @RawValue
did not worked for me yet - runtime error when serializing value.Lucas Ł
06/27/2018, 7:21 AM@Parcelize
data class Foo(val id: Int = 0) : Parcelable {
@IgnoredOnParcel
var bar: Bar? = null
}
The error doesn't appear, even without the @IgnoredOnParcel
annotation
or just do it the old fashioned way, and implement the Parcelable
interface yourself 🙂martynas
06/27/2018, 8:34 AMbar
mutableParceler
.
NoOpParceler : Parceler<Any?> {
override fun create(parcel: Parcel): Any? = null
override fun Any?.write(parcel: Parcel, flags: Int) = Unit
}
kenkyee
06/27/2018, 1:05 PMmartynas
06/27/2018, 4:43 PMkenkyee
06/27/2018, 6:27 PMmartynas
06/28/2018, 6:47 AMLucas Ł
06/28/2018, 6:49 AMkenkyee
06/28/2018, 9:39 AM