Improve save
This commit is contained in:
1 parent
f785848fe0
commit
9495b026b6
8 files changed
+167
-8
No files matched your search
@@ -15,7 +15,10 @@
|
||||
|
||||
package com.hippo.scene;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@@ -111,6 +114,20 @@ public abstract class Scene {
|
||||
finish();
|
||||
}
|
||||
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
SparseArray<Parcelable> states = new SparseArray<>();
|
||||
mRootView.saveHierarchyState(states);
|
||||
outState.putSparseParcelableArray(Integer.toHexString(hashCode()), states);
|
||||
}
|
||||
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
SparseArray<Parcelable> savedStates
|
||||
= savedInstanceState.getSparseParcelableArray(Integer.toHexString(hashCode()));
|
||||
if (savedStates != null) {
|
||||
mRootView.restoreHierarchyState(savedStates);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FragmentManager for interacting with fragments associated
|
||||
* with StageActivity.
|
||||
|
||||
Reference in new issue
Block a user