I want to ignore a field when using the @Parcelize
annotation in Kotlin so that the field is not parceled, since this field does not implement the Parcelable
interface.
Starting with this, we get an error because PagedList
is not parcelable:
@Parcelize
data class LeaderboardState(
val progressShown: Boolean = true,
val pagedList: PagedList<QUser>? = null
) : Parcelable
Gives:
Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'
Marking as @Transient
gives the same error as above:
@Parcelize
data class LeaderboardState(
val progressShown: Boolean = true,
//Same error
@Transient
val pagedList: PagedList<QUser>? = null
) : Parcelable
There is an undocumented annotation I found called @IgnoredOnParcel
which gives the same error, and a lint error on the annotation:
@Parcelize
data class LeaderboardState(
val progressShown: Boolean = true,
//Same error plus lint error on annotation
@IgnoredOnParcel
val pagedList: PagedList<QUser>? = null
) : Parcelable
The lint error in that case is:
@IgnoredOnParcel' is inapplicable to properties declared in the primary constructor
Is there really no way to do this with @Parcelize?