Create new scene after Activity recreate
This commit is contained in:
1 parent
a5bcad9296
commit
224760abf6
6 files changed
+104
-44
No files matched your search
@@ -60,10 +60,20 @@ public abstract class Scene {
|
||||
|
||||
protected static SceneManager sSceneManager;
|
||||
|
||||
private int mId;
|
||||
|
||||
static void setSceneManager(SceneManager sceneManager) {
|
||||
sSceneManager = sceneManager;
|
||||
}
|
||||
|
||||
public Scene() {
|
||||
mId = sSceneManager.nextId();
|
||||
}
|
||||
|
||||
int getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
void setCurtain(@Nullable Curtain curtain) {
|
||||
mCurtain = curtain;
|
||||
}
|
||||
@@ -168,6 +178,10 @@ public abstract class Scene {
|
||||
onResume();
|
||||
}
|
||||
|
||||
void replace(@NonNull Scene oldScene) {
|
||||
onReplace(oldScene);
|
||||
}
|
||||
|
||||
void setFitPaddingBottom(int b) {
|
||||
onGetFitPaddingBottom(b);
|
||||
}
|
||||
@@ -205,8 +219,7 @@ public abstract class Scene {
|
||||
StageActivity sa = getStageActivity();
|
||||
mSceneView = createSceneView(sa);
|
||||
initBackground(mSceneView);
|
||||
mSceneView.addView(view, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
mSceneView.addView(view, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
|
||||
private void initBackground(@NonNull View bg) {
|
||||
@@ -238,6 +251,12 @@ public abstract class Scene {
|
||||
protected void onResume() {
|
||||
}
|
||||
|
||||
protected void onReplace(@NonNull Scene oldScene) {
|
||||
mId = oldScene.mId;
|
||||
mAnnouncer = oldScene.mAnnouncer;
|
||||
mCurtain = oldScene.mCurtain;
|
||||
}
|
||||
|
||||
/**
|
||||
* It will be called if nav bar is transparent.
|
||||
* @param b the nav bar's height
|
||||
@@ -346,7 +365,7 @@ public abstract class Scene {
|
||||
|
||||
// It is constant
|
||||
private String getStateKey() {
|
||||
return "scene:" + Integer.toHexString(hashCode());
|
||||
return "scene:" + mId;
|
||||
}
|
||||
|
||||
private String getIsGoneKey() {
|
||||
|
||||
Reference in new issue
Block a user