Here is my model class:
public enum Action {
RETRY, SETTINGS
}
private int imageId;
private String description;
private String actionName;
private Action ac
Sample Kotlin-Code (null-safe):
writeInt(action?.ordinal ?: -1)
action = readInt().let { if (it >= 0) enumValues()[it] else null }
Which can be encapsulated in a write/readEnum Methods as extensions to Parcel:
fun > Parcel.writeEnum(value: T?) =
writeInt(value?.ordinal ?: -1)
inline fun > Parcel.readEnum(): T? =
readInt().let { if (it >= 0) enumValues()[it] else null }