Created
July 12, 2022 10:47
-
-
Save dmersiyanov/d057f02f825457a25caa3631bd137265 to your computer and use it in GitHub Desktop.
Save state for android custom view
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
internal class SavedState : BaseSavedState { | |
var isExpanded: Boolean = false | |
constructor(superState: Parcelable) : super(superState) | |
constructor(source: Parcel) : super(source) { | |
isExpanded = source.readBoolean() | |
} | |
constructor(source: Parcel?, loader: ClassLoader?) : super(source, loader) | |
override fun writeToParcel(out: Parcel, flags: Int) { | |
super.writeToParcel(out, flags) | |
out.writeBoolean(isExpanded) | |
} | |
companion object { | |
@JvmField | |
val CREATOR: Parcelable.Creator<SavedState> = object : Parcelable.Creator<SavedState> { | |
override fun createFromParcel(source: Parcel) = SavedState(source) | |
override fun newArray(size: Int): Array<SavedState> = newArray(size) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment