Last active
November 1, 2017 03:20
-
-
Save akexorcist/af59afb306bdf2c05de9e7b0a2c3a7ca to your computer and use it in GitHub Desktop.
Simple parcelable model class
This file contains hidden or 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
open class BaseItem(open var type: Int) : Parcelable { | |
constructor(parcel: Parcel) : this( | |
type = parcel.readInt()) | |
override fun writeToParcel(parcel: Parcel, flags: Int) { | |
with(parcel) { | |
writeInt(type) | |
} | |
} | |
... | |
} |
This file contains hidden or 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
class ContentItem : BaseItem { | |
var text: String | |
var title: String | |
constructor(title: String, text: String) : super(ItemType.TYPE_VIDEO) { | |
this.title = title | |
this.text = text | |
} | |
constructor(parcel: Parcel) : super(parcel) { | |
title = parcel.readString() | |
text = parcel.readString() | |
} | |
override fun writeToParcel(parcel: Parcel, flags: Int) { | |
super.writeToParcel(parcel, flags) | |
with(parcel) { | |
writeString(title) | |
writeString(text) | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment