Methods Summary |
---|
protected void | applyPolicyChanges()
if (mSavePolicy == SAVE_LIMITED_CHILD) {
if (mLimitNumber <= 0) {
throw new IllegalArgumentException();
}
if (mChildStates == null || mChildStates.maxSize() != mLimitNumber) {
mChildStates = new LruCache<String, SparseArray<Parcelable>>(mLimitNumber);
}
} else if (mSavePolicy == SAVE_ALL_CHILD || mSavePolicy == SAVE_ON_SCREEN_CHILD) {
if (mChildStates == null || mChildStates.maxSize() != UNLIMITED) {
mChildStates = new LruCache<String, SparseArray<Parcelable>>(UNLIMITED);
}
} else {
mChildStates = null;
}
|
public void | clear()
if (mChildStates != null) {
mChildStates.evictAll();
}
|
public final int | getLimitNumber()
return mLimitNumber;
|
public final int | getSavePolicy()
return mSavePolicy;
|
static java.lang.String | getSaveStatesKey(int id)
return Integer.toString(id);
|
public final void | loadFromBundle(android.os.Bundle savedBundle)
if (mChildStates != null && savedBundle != null) {
mChildStates.evictAll();
for (Iterator<String> i = savedBundle.keySet().iterator(); i.hasNext(); ) {
String key = i.next();
mChildStates.put(key, savedBundle.getSparseParcelableArray(key));
}
}
|
public final void | loadView(android.view.View view, int id)Load view from states, it's none operation if the there is no state associated with the id.
if (mChildStates != null) {
String key = getSaveStatesKey(id);
SparseArray<Parcelable> container = mChildStates.get(key);
if (container != null) {
view.restoreHierarchyState(container);
}
}
|
public void | remove(int id)
if (mChildStates != null && mChildStates.size() != 0) {
mChildStates.remove(getSaveStatesKey(id));
}
|
public final android.os.Bundle | saveAsBundle()
if (mChildStates == null || mChildStates.size() == 0) {
return null;
}
Map<String, SparseArray<Parcelable>> snapshot = mChildStates.snapshot();
Bundle bundle = new Bundle();
for (Iterator<Entry<String, SparseArray<Parcelable>>> i =
snapshot.entrySet().iterator(); i.hasNext(); ) {
Entry<String, SparseArray<Parcelable>> e = i.next();
bundle.putSparseParcelableArray(e.getKey(), e.getValue());
}
return bundle;
|
public final void | saveOffscreenView(android.view.View view, int id)Save off screen views according to policy.
switch (mSavePolicy) {
case SAVE_LIMITED_CHILD:
case SAVE_ALL_CHILD:
saveViewUnchecked(view, id);
break;
case SAVE_ON_SCREEN_CHILD:
remove(id);
break;
default:
break;
}
|
public final void | saveOnScreenView(android.view.View view, int id)The on screen view is saved when policy is not {@link #SAVE_NO_CHILD}.
if (mSavePolicy != SAVE_NO_CHILD) {
saveViewUnchecked(view, id);
}
|
protected final void | saveViewUnchecked(android.view.View view, int id)Save views regardless what's the current policy is.
if (mChildStates != null) {
String key = getSaveStatesKey(id);
SparseArray<Parcelable> container = new SparseArray<Parcelable>();
view.saveHierarchyState(container);
mChildStates.put(key, container);
}
|
public final void | setLimitNumber(int limitNumber)
this.mLimitNumber = limitNumber;
applyPolicyChanges();
|
public final void | setSavePolicy(int savePolicy)
this.mSavePolicy = savePolicy;
applyPolicyChanges();
|