Created
October 25, 2014 19:00
-
-
Save mattleibow/a1c0d058965056f06b98 to your computer and use it in GitHub Desktop.
base for saving android view state
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
// state that this view preserves | |
public class BaseInstanceState : Android.Views.View.BaseSavedState | |
{ | |
// create a new state to be saved | |
public BaseInstanceState(IParcelable superState) | |
: base (superState) | |
{ | |
} | |
// read the values out of the parcel | |
public BaseInstanceState(Parcel parcel) | |
: base (parcel) | |
{ | |
ReadFromParcel (parcel); | |
} | |
// read the values out of the parcel | |
public virtual void ReadFromParcel (Parcel source) | |
{ | |
} | |
// write the values into the parcel | |
public override void WriteToParcel (Parcel dest, ParcelableWriteFlags flags) | |
{ | |
base.WriteToParcel (dest, flags); | |
} | |
// create the field that is used by Android | |
[ExportField("CREATOR")] | |
private static InstanceStateCreator InitializeCreator() | |
{ | |
return new InstanceStateCreator (); | |
} | |
private class InstanceStateCreator : Java.Lang.Object, IParcelableCreator | |
{ | |
public Java.Lang.Object CreateFromParcel (Parcel source) | |
{ | |
return new BaseInstanceState (source); | |
} | |
public Java.Lang.Object[] NewArray (int size) | |
{ | |
return new BaseInstanceState[size]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment