Created
May 10, 2020 10:51
-
-
Save akexorcist/776c45ea57f9a5ab28d90bb6ed13a3be to your computer and use it in GitHub Desktop.
Using Parcelable.ClassLoaderCreator instead of Parcelable.Creator in derived class to support inherited 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
class RegularPostView : BasePostView { | |
... | |
internal class SavedState : AbsSavedState { | |
... | |
companion object { | |
@JvmField | |
val CREATOR: Parcelable.ClassLoaderCreator<SavedState> = object : Parcelable.ClassLoaderCreator<SavedState> { | |
override fun createFromParcel(source: Parcel, loader: ClassLoader): SavedState { | |
return SavedState(source, loader) | |
} | |
override fun createFromParcel(source: Parcel): SavedState { | |
return SavedState(source, null) | |
} | |
override fun newArray(size: Int): Array<SavedState> { | |
return newArray(size) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment