public final class StateSaver extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ANDROID_PREFIX |
static String |
JAVA_PREFIX |
static String |
SUFFIX |
Modifier and Type | Method and Description |
---|---|
static <T> void |
restoreInstanceState(T target,
Bundle state)
Restore the given
target from the passed in Bundle . |
static <T extends View> |
restoreInstanceState(T target,
Parcelable state)
Restore the sate of the given view and return the super state of the parent class.
|
static <T> void |
saveInstanceState(T target,
Bundle state)
Save the given
target in the passed in Bundle . |
static <T extends View> |
saveInstanceState(T target,
Parcelable state)
Save the state of the given view and the other state inside of the returned
Parcelable . |
static void |
setEnabledForAllActivitiesAndSupportFragments(Application application,
boolean enabled)
Turns automatic instance saving on or off for all activities and fragments from the support library.
|
public static final String SUFFIX
public static final String ANDROID_PREFIX
public static final String JAVA_PREFIX
public static <T> void saveInstanceState(T target, Bundle state)
target
in the passed in Bundle
.target
- The object containing fields annotated with State
.state
- The object is saved into this bundle.public static <T> void restoreInstanceState(T target, Bundle state)
target
from the passed in Bundle
.target
- The object containing fields annotated with State
.state
- The object is being restored from this bundle. Nothing is restored if the argument is null
.public static <T extends View> Parcelable saveInstanceState(T target, Parcelable state)
Parcelable
.target
- The view containing fields annotated with State
.state
- The super state of the parent class of the view. Usually it isn't null
.public static <T extends View> Parcelable restoreInstanceState(T target, Parcelable state)
target
- The view containing fields annotated with State
.state
- The parcelable containing the view's state and its super sate.null
.public static void setEnabledForAllActivitiesAndSupportFragments(Application application, boolean enabled)
saveInstanceState(Object, Bundle)
and restoreInstanceState(Object, Bundle)
, instead
the library is doing this automatically for you. It's still necessary to annotate fields with State
, though.
Application#onCreate()
method.application
- Your application instance.enabled
- Whether this feature should be enabled.