-
-
Save dilrajsingh1997/c163fc74690630739a285cd7a3a8ed09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class User( | |
val id: Int, | |
val name: String | |
) : Parcelable { | |
constructor(parcel: Parcel) : this( | |
parcel.readInt(), | |
parcel.readString() ?: "" | |
) | |
override fun writeToParcel(parcel: Parcel, flags: Int) { | |
parcel.writeInt(id) | |
parcel.writeString(name) | |
} | |
override fun describeContents(): Int { | |
return 0 | |
} | |
companion object CREATOR : Parcelable.Creator<User> { | |
override fun createFromParcel(parcel: Parcel): User { | |
return User(parcel) | |
} | |
override fun newArray(size: Int): Array<User?> { | |
return arrayOfNulls(size) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment